How to get the reference of a property dynamically in Pega
I have a requirement where I need to have a generic when condition on a property, this when condition will call a decision table and Decision table will return true/false.
based on the output from decision table, the field will be shown or hidden.
The first column in the DT is the Property name, I need to compare this with the reference property from where the when rule was triggered, I am not able to get that reference of the property dynamically. Can someone help ?
I tried using tools.getActive() but not supported in java function.
Or suggest any other solution?
***Updated by moderator: Lochan to update platform capability***
Here's a basic (and you will need to improve on this, to make sure it is bullet-proof for your particular requirements) Java Step which dynamically looks up a Property Value , based on a Parameter Name:
But, in my case, I am calling a when on a property and we cannot pass a value to a parameter when we refer a when condition on the property. So cant use the parameter. Need something internal to pega which can be used to get the current property reference from where the when condition is called.
I'm a little hazy on your use-case here; but it sounds like you need to pass a reference to a property down to a DT; but *not* using the Parameter Page....
A sort of 'argument %1' type of idea ? I'm not sure on that to be honest... Is this so you can create a single re-usable DT that can be re-used - without 'committing' to a specific Property ? Can you provide the use-case in more detail (some screenshots or something) showing how your mechanism works with a *static* /hardcoded property - and highlight on how you need to 'slot-in' the dynamic reference ?
So here is a detailed requirement I am trying to achieve
I have a section which have multiple fields on it. On each field I need to use the same when condition for visibility. Here I need to use a decision table in the when condition and pass the name of the property to the decision table dynamically.
Based on the input property name coming to the decision table, it will return true/false and thus the visibility will be controlled.
I am using decision table because in future I want to add other parameters to derive visibility logic. Also I have many sections which would use this when condition in similar manner .
You can create a custom control to conditionally display the property on UI. The control should read the property name using "tools.getActive().getName()" (this may not work same for embedded and top level properties, refer engine help) and set it on parameter page. Write when condition to read the param value and return true or false based on decision table.