Friday, August 9, 2024

Update erlaststatuschangedate in ISIM with a TDI HR Feed

IBM has a support article on this topic here:

https://www.ibm.com/support/pages/how-update-erlaststatuschangedate-through-tdi-hr-feed#:~:text=If%20the%20%22erpersonstatus%22%20attribute%20value%20is%20being%20modified,Work%20attribute%20called%20%22erlaststatuschange%22%20to%20the%20Input%20Map 

Unfortunately, the code provided is incorrect and will throw an exception if you try to use it.

Here's the corrected code:

// set up variables to set the erlaststatuschangedate attribute
// get milliseconds since epoch in local time zone.
var mydate = new Date().valueOf();
// get milliseconds of offset from Zulu/UTC
var localOffset = new Date().getTimezoneOffset() * 60000;
// add/subtract milliseconds based on local timezone to get Zulu time.
var myTZ = mydate + localOffset;
// create a new Date() object representing "now" in Zulu time.
var utcDate = new Date(myTZ);
// Format the date into a string in the correct format
var myTZStr = new java.text.SimpleDateFormat("yyyyMMddHHmm").format(utcDate);
// Add "Z" to the end of the string to complete the correct format.
var myTZStrZ = myTZStr + "Z";
// set the value of erlaststatuschangedate
work.setAttribute("erlaststatuschangedate",myTZStrZ);

No comments: