Maximo Scripting: Date Dizziness - Part III
agrippa 06000202D9 Comment (1) Visits (17082)
The scenario is exactly the same as Part II, so I will not go over the set up details again. Please review Part II if you need to understand how scripting is exploited to calculate dates. To summarize: I created an escalation that runs every minute, executing an action that checks Service Request (SR) records. If a record meets certain criteria, then the script associated with the action calculates target contact date and target start date and applies them back to the SR record.
I followed these steps:
New action launch point, action and script
As I coded this script, I ran into a number of problems. Here are the problems and how I overcame them:
In the function, the call to Date.getUTCMonth() is followed by a ‘+1’ since that method returns an integer between 0 and 11 what we need is an integer between 1 and 12.
By including a simple println() statement within the body of the script, one can view the output of the ISODateString() function. It is similar to:
The pad() function inside the ISODateString() function is used to place a zero to the left of the number (month, date, hours, minutes or seconds) if that number is below 10 to ensure the final string is ISO 8601 compliant.
Testing the new script
With these code changes, the script begins to work as expected populating the SR record’s Target Contact Date and Target Start Date. To test follow these steps (the escalation definition was set up in Part II):
Files with this article