Visibility Expressions in Pega
In Pega, any HTML form control such as a input textbox, textarea, dropdown menu or even just a basic label can be hidden whenever the business scenario arises.
One visibility scenario could be that given certain selection in the first control determines whether to show or hide the second control. The two main solutions for this dynamic scenario are constructed through either a Visibility expression or a When rule.
Expression vs When
Now the evaluation of such Visibility expression runs client-side, the benefit is that the UX is responsive and quick. No round trip to PRPC is needed for showing or hiding.
In contrast, for the updated values to reach the When rule you need to Post and Refresh by means of an event actions set on the first control. Only then the server is made aware and can evaluate those property changes. This approach is somewhat slower, but When rules are more powerful than inline expressions and are often preferred because of maintenance reasons.
When relying on server-side data transforms for setting properties that also have visibility expressions to hide them things can pretty interesting.
For example the standard Participants gadget does not refresh .pyFullName on the client-side because the default rule pyMiniPartyDetails has a Visibility expression set on .pyLabel and .pyPartyLabel. The generated browser script seems not to be aware that its value has been changed by some data transform on the server (UpdateFullName). The participants name remains unaffected when submitting without the textbox losing focus (i.e. pressing the Tab key).
Analysis & Fix
According to the Tracer and Clipboard this data transform to concatenate .pyFirstName and .pyLastName did execute as part of the Change event actions. Apart from the fact those label properties could potentially both by null, the client-side visibility expression still needs something in order to refresh .pyFullName in the gadget.
Prefix such a visibility expression with its own ".Property != ´´ && " or in this case rewrite the full expression to:
.pyFullName != ´´ && .pyPartyRole != ´´
Tip: Make sure you set Visibility of properties based on (at least) the value of the property itself otherwise it might not refresh on screen.
The above behavior has been observed in Pega 7.2.1, but could be easily fixed by overwriting the pyMiniPartyDetails rule. Also remember to disable the “Run visibility on client” option whenever you rely on server-side Clipboard data. [Edgar] (5/19/2017 12:51:31 AM)
@edgarverburgTweets by @edgarverburg
Edgar is a software engineer with experience in TIBCO Middleware and Pega Case Managemement. He holds a master's degree in Computer Science with a specialization in Data Visualization & Computer Graphics.
In his spare time Edgar reads SOS and Empire, mixes house music, blogs and writes film reviews or goes running.
Currently employed by SynTouch he is specifically looking for a PRPC project. Feel free to contact him for challenging assignments through LinkedIn.