Question
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Morgan Stanley
IN
Last activity: 10 Oct 2021 8:09 EDT
Dynamic property expression calculation
Hi,
I have a couple of properties on Clipboard and i would like to do some computations dynamically like below
.First = 10
.Second = 10
Expression: ".First + .Second"
I would like to dynamically calculate the expression value, as we do with expression builder.
Do we have any OOTB function or java api
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689952000/f3c60dbf-4ddc-4c99-a321-10420d56dc21.png?itok=gqM9ZK-3)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689952000/f3c60dbf-4ddc-4c99-a321-10420d56dc21.png?itok=gqM9ZK-3)
Pegasystems Inc.
GB
@Avinash.Haridasu , did you check this https://community.pega.com/knowledgebase/articles/application-development/84/about-declare-expression-rules?
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Pegasystems Inc.
IN
@Avinash.HaridasuDo you mean dynamically means the properties will differ or only values of properties?
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Morgan Stanley
IN
@pavan3753 yes Properties will also differ and also the calculation also differs.
Now i have .First + .Second, Later i might pass .First / .Second or .ABC * .XYZ
They are dynamic and i cant use a declare expression @AngelHermira
I'm looking for some function or java api, which can accept the calculation .First + .Second + .Anything as an argument, and return the result.
As we do with the test functionality of expression builder popup.
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689952000/f3c60dbf-4ddc-4c99-a321-10420d56dc21.png?itok=gqM9ZK-3)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689952000/f3c60dbf-4ddc-4c99-a321-10420d56dc21.png?itok=gqM9ZK-3)
Pegasystems Inc.
GB
How are you intending to compose and validate the formula (variables with operations) that will be the parameter to the function? you can pass the formula as a parameter but validating the references and operations might be the bigger cost depending on how you are planning to do that.
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Morgan Stanley
IN
@Angel Hermira Yes, You're right.
My operations are very simple, not intending to have more than two or three props.
Not sure if we have any function OOTB or if test in expression builder is exposed to clients.
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689952000/f3c60dbf-4ddc-4c99-a321-10420d56dc21.png?itok=gqM9ZK-3)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689952000/f3c60dbf-4ddc-4c99-a321-10420d56dc21.png?itok=gqM9ZK-3)
Pegasystems Inc.
GB
Sorry, but I still don't understand how the formula will be created. Do you plan to expose the text in a business portal?, do you plan to expose Expression builder if available?, do you plan to create a UI to handle it?
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Morgan Stanley
IN
@Angel Hermira Yes, that formula will be part of a data type managed by us
Updated: 24 Sep 2021 11:16 EDT
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Pegasystems Inc.
IN
@Avinash.Haridasu see if the attached approach works using GetPropertyValue function.
1. Capture your property names in two parameters (ex. FirstProp and SecondProp)
2. Get the values of the properties in another two params (ex.FirstPropMap, SecondPropMap) using function i.e. @GetPropertyValue(Param.SecondProp,tools)
3. Based on the mathematic operator captured (Ex. Operand) define the logic
Property names are passed to the parameters FirstProp and SecondProp
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Pegasystems Inc.
IN
@Avinash.Haridasu pyCount and pxResultCount are OOTB properties used for testing instead of creating new properties. Those are not intended for counting in the example
Updated: 24 Sep 2021 13:58 EDT
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Morgan Stanley
IN
@kalls4 I think you got me wrong.
I meant to say my properties are very different in data type.
.A + .B + .C and so on or .A * .B etc or .A + 100
The number of properties are different and in our case we used two..
I'm trying to understand if i could leverage the same API used in expression builder test .
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Morgan Stanley
IN
I'm still awaiting some suggestions from the forum
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689988000/55a90292-dc0d-4504-9b10-a53274d297d6.jpg?itok=eg2Y60Lb)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689988000/55a90292-dc0d-4504-9b10-a53274d297d6.jpg?itok=eg2Y60Lb)
Maantic
IN
can these expressions be categorized in such a way that based on input value to a decision table/decision tree it can return the expression ".A + .B + .C" OR ".A * .B" OR ".A + 100" ?