Support Article
Inconsistent output from OOTB functions for date type property
Summary
The Out-of-the-box(OOTB) functions pxConvertPageToString and pxConvertStringToPage behaves Inconsistently for date and datetime type properties.
PxConvertPageToString Current behavior with input format (Date - YYYYMMDD and Datetime - YYYYMMDDTHHMMSS GMT)
Input - Clipboard
Date - 20161003
DateTime- 20161003T054142.647 GMT
Output is in format (Date - YYYY-MM-DD and DateTime - YYYY-MM-DDTHH:MM:SS Z)
Date:2016-10-03
Datetime:2016-10-03T05:41:42.647Z
However when the pxConvertStringToPage is used and JSON with format (Date - YYYY-MM-DD and DateTime - YYYY-MM-DDTHH:MM:SS Z) is passed with the following inputs:
Date:2016-10-03
Datetime:2016-10-03T05:41:42.647Z
The output format remains the same.
If the function PxConvertPageToString with input format (Date - YYYYMMDD and Datetime - YYYYMMDDTHHMMSS GMT) converts to (Date - YYYY-MM-DD and DateTime - YYYY-MM-DDTHH:MM:SS Z) then, ideally the reverse function pxConvertStringToPage should convert back to format (Date - YYYYMMDD and Datetime - YYYYMMDDTHHMMSS GMT).
What should be the input Date and DateTime format so that the functions PxConvertPageToString and pxConvertStringToPage behaves consistently?
Error Messages
If the function PxConvertPageToString with input format (Date - YYYYMMDD and Datetime - YYYYMMDDTHHMMSS GMT) converts to (Date - YYYY-MM-DD and DateTime - YYYY-MM-DDTHH:MM:SS Z) then, ideally the reverse function pxConvertStringToPage should convert back to format (Date - YYYYMMDD and Datetime - YYYYMMDDTHHMMSS GMT).
Steps to Reproduce
For Function PxConvertPageToString:
1. Create a Temppage say mypage.
2. Do a Property-set on mypage for single value properties of types(Date and DateTime) with values.
For example:
Property mydate as Date and value "20161013"
Property mydatetime as DateTime and value "20161003T054142.647 GMT"
3. Create a Out Parameter say JSONString.
4. Set Param.JSONString as @(Pega-RULES:Page).pxConvertPageToString(tools, myStepPage, "json")
5. Do a show property for Param.JSONString. The generated JSON will be similar to { "mydate":"2016-10-13" ,"mydatetime":"2016-10-03T05:41:42.647Z", "pxObjClass":"ORG-APP-Work-APPCASE" }
6. Notice the Output is in format (Date - YYYY-MM-DD and DateTime - YYYY-MM-DDTHH:MM:SS Z)
For Function pxConvertStringToPage:
In an Activity do the below steps:
1.Create a Step Page say mypage2.
2. Add parameters "jsonstring" as string and out.
3. Do a property set and set Param.jsonstring with the value @(Pega-RULES:Page).pxConvertStringToPage(tools, myStepPage, Param.jsonstring,"json").
4. Run the activity and pass the valid JSON (generated in previous PxConvertPageToString function) to the parameter "jsonstring" { "mydate":"2016-10-13" ,"mydatetime":"2016-10-03T05:41:42.647Z", "pxObjClass":"ORG-APP-Work-APPCASE" } . Here it is passing JSON with format (Date - YYYY-MM-DD and DateTime - YYYY-MM-DDTHH:MM:SS Z).
5. Open the clipboard and open the page mypage2.
6.Notice that the out put format is same as input format (Date - YYYY-MM-DD and DateTime - YYYY-MM-DDTHH:MM:SS Z).
Root Cause
The OOTB functions pxConvertStringToPage and PxConvertPageToString is behaving as per design. This is not a bug.
Resolution
In case of pxConvertStringToPage, the type information is not present in the JSON inpit, thus the values are considered as text type properties causing no change in the format.
In the case of PxConvertPageToString the types(DateTime and Date) are intact and converted to the DateTime and Date type properties to ISO_8601 format.
Published October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.