Question
Adqura
TR
Last activity: 29 Jul 2016 16:42 EDT
How to call getPropertyField function to dynamically pick a value
Hi,
Based on a business rule I am trying to pick a property from customer data class. In order to do so, I am calling getPropertyField function to get the related property's value. It's signature is getPropertyField--(String,String,String,PublicAPI)
and called like this @Utilities.getPropertyField(strClassName,strPropertyName,fieldname,tools).
And this is how I call it; @Utilities.getPropertyField("NBAFW-Data-Customer","SegmentKodu","SegmentKodu",tools), it always returns null. As per documentation function "Returns the value of the named property (fieldname) in the Rule-Obj-Property instance that defines the specified property (strPropertyName) in the named class (strClassName).".
Usage of strPropertyName and fieldname is not clear to me. They sound to be the same thing. I appreciate if somebody can show me the right usage of the funciton or a different way of accesing a property's value.
Regards,
Oğuz
p.s. Pega 7.2 & Pega Marketing 7.13
***Updated by Moderator: Marissa to update categories***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Adqura
TR
Hi,
I wrote a new function to fetch property's value from clipboard; there are two inputs page, name and property name. This is how I call the function;
@String.toDecimal(@CustomFunctions.GetPropertyValue("ProductPrioritization", "P3000202000_Int") )
Second parameter is hardcoded above. In my strategy, inside the Set Property shape, it is a SR property that concatanates product code and channel.
And custom function looks like this;
/* Get tools reference */
PublicAPI tools = null;
PRThread thisThread = (PRThread)ThreadContainer.get();
tools = thisThread.getPublicAPI();
/* Get the property value from ClipboardProperty */
ClipboardProperty prop = tools.getProperty(pageName + "." + propertyName);
String propertyValue = prop.getStringValue();
return propertyValue ;
Regards,
Oğuz
Northbridge
CA
Does this help in your scenario?
tools.getProperty("propertyname").getStringValue();
Adqura
TR
In theory it should but tools.getProperty is not available inside the expression builder... I see only 5 functions.
Northbridge
CA
Do you need the value of the property or the field value??
If you just want to get the value of a property then you can select it from "properties" option on the left like shown in the above figure. Or you can access them with a dot prefix like .propertyName .
Adqura
TR
I know but I want it to be dynamic. When I type Primary.SegmentKodu, I can access the property, and eventually to its value. What I want is to make it automatic.
My use case is this: I've 200 propositions and each has a propensity score for each channel, per customer. This customer level data is stored in an Oracle table like this;
I can construct the column/property name (e.g. Prop1_ATM) in run-time, all I want is to get the value of that property.
Please let me know if there is a way of doing this.
Regards,
Oğuz
Blue Rose Technologies GmbH
DE
Hi Oguz,
If I understand correctly, you will only come to know the property name/field that is holding the acutal value during run time. Now this property name will be part of another property and that has to be resolved to get the value. Is this what you need to accompolish ?
Adqura
TR
Yes, indeed SanthishKumar.
Property name is derived from Proposition Identifier and incoming channel value from REST API, all run-time parameters. I can construct the property name such as "iPhoneSpecialOffer_Internet". I know the name of the class in design time anyway. Thus, all I need is to get the value of e.g. iPhoneSpecialOffer_WEB or Prop1_Branch.
However, available public API returns null.
Regards,
Oğuz
Adqura
TR
Do you have any update for me?
Pegasystems Inc.
US
It sounds simple and you might have already tried it but a simple java step does it rt if not an OOTB utility.
- In a java step you can get the value of the property using PublicAPI methods like tools.getProperty(<<property_identifier>>).getStringValue(); or if it is inside a page you can get it using page functions like tools.getStepPage() or tools.getPage("<<>>") or getParentPage() etc.
- Assign it to a local variable and use it in when condition in next step
Adqura
TR
Hi Durgaprasad,
I am in Pega Marketing strategy canvas, java steps cannot be applied. I will try to write a function or activity and try to apply the steps you mentioned in there and call it accordingly. Let's see if it is going to work out.
Thanks,
p.s. It is really weird that there is no API available for that in the expression builder...
Accepted Solution
Adqura
TR
Hi,
I wrote a new function to fetch property's value from clipboard; there are two inputs page, name and property name. This is how I call the function;
@String.toDecimal(@CustomFunctions.GetPropertyValue("ProductPrioritization", "P3000202000_Int") )
Second parameter is hardcoded above. In my strategy, inside the Set Property shape, it is a SR property that concatanates product code and channel.
And custom function looks like this;
/* Get tools reference */
PublicAPI tools = null;
PRThread thisThread = (PRThread)ThreadContainer.get();
tools = thisThread.getPublicAPI();
/* Get the property value from ClipboardProperty */
ClipboardProperty prop = tools.getProperty(pageName + "." + propertyName);
String propertyValue = prop.getStringValue();
return propertyValue ;
Regards,
Oğuz