In a section I have a button with an action set. On click:
Action 1 - Run data transform: runs some business logic to find a customer. If a customer is found, set .pyText == .ContactId. Otherwise .pyText==“”
Action 2 - [WHEN .pyText==“”] Local action: no customer was found - display a local action containing an error message
Action 3 - [WHEN .pyText!=“”] Landing page: a customer is found - open their 360 view
The issue is the when conditions are evaluated on load of the section, and not on click of the button. As when the section loads my data transform has not run yet, when clicking the button I always get the Local action, even if a customer has been found.
How can I force Pega to re-evaluate the when conditions? Is there a workaround for this issue?
This does not work: if I refresh the section after running the data transform, I would need to click the button twice to get the wanted result.
On load, .pyText==“” so the landing page action is not executed when I click the button the first time. On click, the section is refreshed, so .pyText has a value → when I click the button a second time, the when conditions will be evaluated based on the result of the data transform at the time of the first click.
Note: this is a very far-fetched solution, but I will leave here as it may be helpful to me
Pega is not evaluating the when condition on load, I thought the same before. Actually Pega takes the current value of .pyText to evaluate the condition, but it takes the client-side value, not the one in the server side.
You need a way to get the server-side of .pyText and set it to a field in order for Pega to be able to read that value.
I created a video to show a possible solution. Please let me know if you have any question.
After your Run DataTransform action, add an action “Refresh Section” and configure it to refresh the new section embedded in step 2 (do not forget to check the disable submit on refresh).
Wow thank you so much for your answers!
The solution you suggested in the video did not work for me. But your second solution works! It also works by putting the hidden text directly inside the section (without using an embedded section), and using the Refresh-This section action (with the ‘disable submit on refresh’ option checked).