- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a requirement in ServiceNow based on created time of incident, that time will be converted into other time zones for Singapore and Japan and India. for that i have created 3 fields with different time zones. IST time SGT time and JST time. Now if i create an incident, that incident created based on IST time zone , because user from IST, now that time will be convert into IST time(u_ist_time), SGT time(u_sgt_time) and JST time(u_jst_time).
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
You can follow this business rule (Before) for your particular use case.
(function executeRule(current, previous) {
function convertToTZDateTime(baseGdt, zone) {
var g = new GlideDateTime(baseGdt);
// Set display timezone
g.setTimeZone(zone);
var local = g.getDisplayValue(); // "yyyy-MM-dd HH:mm:ss"
var finalGDT = new GlideDateTime();
finalGDT.setDisplayValue(local);
return finalGDT;
}
var created = current.sys_created_on.getGlideObject();
current.u_ist = convertToTZDateTime(created, "Asia/Kolkata");
current.u_sgt = convertToTZDateTime(created, "Asia/Singapore");
current.u_jst = convertToTZDateTime(created, "Asia/Tokyo");
})(current, previous);
best practice is as @Palash_Sarkar has mentioned in his comment
Please mark it as helpful/solution accepted if you find this useful
Thanks and Regards,
Mohammed Zakir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Ankur,
Thank you for your Quick response.
Yes client needs, three new fields on the incident form
and based on created time, those three fields should be automatically updated with respective time zones(IST,SGT and JST)