Question

Unable to find any function to convert property to String

We are using Pega Infinity 8.1.1. We have a decimal property that we want to convert to date. toDate function is not able to do it directly as it's setting the value to default date 01/01/1970. So, I was trying to convert the decimal into string and then format that value with FormatDateTime function.But, I am not getting any toString() function to convert any property to string format. Please feel free to suggest necessary actions to be taken on this.

Correct Answer
October 16, 2019 - 4:25am

Hi @RumelaB4,

I guess you have found a solution to convert the decimal to string by writing a code.

However, when you assign a decimal property value to a text property, Pega will take care of the conversion. 

I configured a similar use case where I am entering a 20190101. in a decimal property. A OnChange action set is configured to with Post Value and Refresh This Section (I am calling Data Transform while Refreshing) the section). In the data transform I am assigning the decimal property value to Text property. After this we can convert to date property with OOTB function. This worked for me.

Hope this also helps you.

Regards,

Priyabharathi 

 

Comments

Keep up to date on this post and subscribe to comments

October 3, 2019 - 6:45pm

can you give an example of how your decimal format date looks like?

October 4, 2019 - 9:22am
Response to WaikeiKwok_GCS

The value of the property is like : 20190101. Property type is NUMBER   in DataBase and DECIMAL in PEGA.

October 4, 2019 - 7:31pm
Response to RumelaB4

A java step like below may do it?

 

// e.g. Dec1 is decimal with value 19700101.0
Double dec1 = myStepPage.getProperty("Dec1").toDouble();
java.text.DecimalFormat decimalFormat = new java.text.DecimalFormat("#");
String output = decimalFormat.format(dec1);
oLog.infoForced("output: " + output);

October 14, 2019 - 9:24am
Response to WaikeiKwok_GCS

MyStepPage was not working in this syntax though I have written the code by creating a function and built it through JAVA. It's working fine.Thanks for your assistance.

October 16, 2019 - 4:25am

Hi @RumelaB4,

I guess you have found a solution to convert the decimal to string by writing a code.

However, when you assign a decimal property value to a text property, Pega will take care of the conversion. 

I configured a similar use case where I am entering a 20190101. in a decimal property. A OnChange action set is configured to with Post Value and Refresh This Section (I am calling Data Transform while Refreshing) the section). In the data transform I am assigning the decimal property value to Text property. After this we can convert to date property with OOTB function. This worked for me.

Hope this also helps you.

Regards,

Priyabharathi 

 

October 16, 2019 - 9:46am
Response to Priyabharathi

Hi Priyabharathi, Yes the property value we need to convert is not loaded when we are running the strategy standalone. It's loaded only when the campaign is being run. And I have used the same method you have mentioned and it's working fine now.Thanks for the assistance.