In action sets when conditions are evaluated on screen load instead of on event

Hello Pega community,

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?

Thank you for your help.

@DorianeLovesPega Can the layout/section containing the button be refreshed when the logic of customer found or not is executed?

@BhanuPrakash_G

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.

@DorianeLovesPega

Note: this is a very far-fetched solution, but I will leave here as it may be helpful to me :slight_smile:

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.

@DorianeLovesPega Here is another solution:

  1. Create a new section with only a hidden input text: .pyText.

  1. Embed the created section into your existing section.

  1. 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).

  1. Test it!

@Deivit

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).

@DorianeLovesPega Great to hear it worked! Although it didn’t work for me refreshing the same section.

Edit: It worked refreshing the same section :slight_smile: