Time difference on MRVS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I have a multi-row variable set with one variable in it that is a Date/Time variable. I'm running a script in the workflow to place the values from the MRVS into the work notes. When doing so, the Date is fine but the time is 4 hours after the time that is in the variable set. I have tried several things like using getDisplayValue in the MRVS loop part of the script, but when I do that, the work notes show "undefined" for the values. Any help/suggestions are appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi there @MonicaW
can u share tthe script
Kind Regards,
Azar
Serivenow Rising Star ⭐
Developer @ KPMG.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @MonicaW
You are getting the issue for time difference between UTC and local time.
To fix your issue , you must initialize a GlideDateTime object with the MRVS value and then use the getDisplay() method to convert it back to the local timezone.
Sample code/ not tested/ update it as per your requirement:
var mrvs = current.variables.your_mrvs_internal_name; // replace your mrvs var name
var mrvsData = JSON.parse(mrvs);
var workNotesMsg = "MRVS Data:\n";
for (var i = 0; i < mrvsData.length; i++) {
var testDateTime = mrvsData[i].your_date_time_variable;
var gdt = new GlideDateTime(testDateTime);
var localDateTime = gdt.getDisplayValue(); //Retrieve formatted display value (local to the user/system)
workNotesMsg += "Row " + (i + 1) + " Date/Time: " + localDateTime + "\n";
}
current.work_notes = workNotesMsg;
