how to convert date Time to customer timezone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2017 03:34 AM
Hi All,
I have strucked with timezone while converting GlideDateTime to user's timezone.Can anyone help me how to convert to user's timezone.
Below code is written in after update inorder to calculate delivery time and set in due date on RITM and TASK.
(function executeRule(current, previous /*null when async*/) {
var dueDate = current.due_date.getDisplayValue();
var nowDate1 = gs.nowDateTime();
var deliveryTime ='';
var totalTime = '';
var expectedTime = current.cat_item.delivery_time.getDisplayValue().toString();
deliveryTime = expectedTime.split(' ')[0];
var gdt = new GlideDateTime(nowDate1);
gdt.addDays(deliveryTime);
gs.log('gdt - ' + gdt,'swathi');
totalTime = gdt;
gs.log('totalTime' + totalTime,'swathi');
var sc = new GlideRecord('sc_task');
sc.addQuery('request_item', current.sys_id);
sc.query();
if(sc.next()){
gs.log('inside Task','swathi');
sc.due_date = totalTime.getDisplayValue();
sc.update();
}
current.due_date = totalTime.getDisplayValue();
current.update();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2017 04:31 AM
Hi Swathi,
Any update on this?
Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2017 05:25 AM
Hi Swati,
We are calculating Due Date from Delivery Time.
you have to write before Insert Business rule on sc_req_item table and coming to inside script use below code,
var grCatItem = new GlideRecord('sc_cat_item'); | |
grCatItem.addQuery('sys_id',current.cat_item); |
grCatItem.query();
if(grCatItem.next()){
var dur = grCatItem.delivery_time.getDisplayValue(); | |
var days = dur.split(' ')[0]; | |
var gdt = new GlideDateTime(); | |
gdt.addDays(days); | |
current.due_date = gdt; |
}
Pls hit correct if this helpful