I'm trying to get current datetime within the offline mobile application. Requirement is that a certain field in UI should capture current date and time by default and user will have the ability to change it. Is this achievable in offline mobile?
I've tried using @getCurrentTimeStamp() as the "Default Value" for the property in section. But that gives me the timestamp of last full sync - not the current time stamp. Also tried using the function in pre-flowaction DT. But pega fails to run that DT as there is a function call in it.
Appreciate any suggestions on this..
***Edited by Moderator: Pallavi to update platform capability tags***
1. You can have a Page type Data Page for example D_ServiceDate and source it from a Data Transform. You can set the Date property .ServiceDate property inside Data Transform using functions for example @dateTime.CurrentDate("yyyyMMdd",pxRequestor.pyUseTimeZone). You can use D_ServiceDate.ServiceDate as property for the control in section.
2. You can set the value to clipboard property using java script before displaying the section.
var serviceDate = pega.functions.DateTimeLibrary.getCurrentTimeStamp();
workPage = pega.ui.ClientCache.find("pyWorkPage");
Both these approaches should be returning proper date/time values. Please try and let us know if you face any issues.
Approach 1 is caching the data page and still displaying sync date time
Approach 2 - How do you propose we call the script function though? This is the first section that's loading in that case - and I tried adding some <script>alert(1)</script> into a label to check if inline script works and that didnt work.