Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

JSON conversion for Blank Date to 19700101

SA-29193

Summary



User installed the HFix-29848 and customized the Out-of-the-box (OOTB) function pxConvertPageToString so that the JSON conversion includes the string value pairs having null ("") value (SR-A100365).

For all other datatypes the conversion works fine with respect to null valeus.

But For Date and datetime, the converted JSON gives the string as "P_Date":"19700101" and "P_DateTime":"19700101T000000.000Z" respectively.


Error Messages



​The generated JSON has default date and datetime value set, however the input for the same properties have null value .

Input - Clipboard
P_Date-""
P_DateTime-""

Customized Function used myConvertPageToString() after saving as the OOTB pxConvertPageToString

Output - JSON
"P_Date":"19700101"
"P_DateTime":"19700101T000000.000Z"


Steps to Reproduce



1. Download the HFix-29848.
2. Use update manager to install the Hotfix without committing it.
3. Restart the Pega server.
4. Search and open the library “Page” and save it in your local ruleset with or without a new name and compile it.
5. Open the OOTB function pxConvertPageToString and click Save as in the local ruleset.
6. Edit the identifier and rename it. For example, “myConvertPageToString”.
7. Update the library name if it is renamed during saving it into local ruleset.
8. Click Create and Open button.
9. Go to the java tab and insert the local change at line number 4 as follows:

 

aOptions.putString(com.pega.pegarules.priv.clipboard.PegaClipboardPage.JsonFormatOptions.Encode.toString(), "false"); <-- line 3
aOptions.putString(com.pega.pegarules.priv.clipboard.PegaClipboardPage.JsonFormatOptions.ALLOW_EMPTY_PROPERTIES.toString(), "true"); <-- line 4

10. Click the save button then compile, generate function and library.
11. Create a Temppage
12. Do a Property-set on TempPage for single value properties of type Date and DateTime with value ""
For example:


Property Username as string and value "john"
Property P_Date as Date and value ""
Property P_DateTime as DateTime and value ""

13. Create a Out Parameter say JSONString.
14. Set Param.JSONString as @(MyRuleset:MyPage).myConvertPageToString(tools, myStepPage, "json") /* Using custom new function */
15. Do a show property for Param.JSONString.

​The generated JSON will be similar to { "Name":"john" , "P_Date":"19700101" ,P_DateTime":"19700101T000000.000Z" ,"pxObjClass":"ORG-APP-Work-APPCASE" }
Notice the property P_Date has value set to 19700101 and
P_DateTime has value set to 19700101T000000.000Z


Root Cause



It is a default behavior to set the Date to epoch date, that is 01-01-1970, when any java operations are performed on an empty Date/DateTime type property

Resolution



User is suggested to set the following Dynamic system setting's value to "true" for these DSS's owning ruleset is "Pega-IntegrationEngine".

1. For Date property         : use dynamic system setting "disableEpochDate".
2. For DateTime property     : use dynamic system setting "disableEpochDateTime".
 

Related PDN article:

https://pdn.pega.com/support-articles/datetime-set-01-01-1970-when-property-value-empty

Published October 25, 2016 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice