- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2021 12:34 PM
You should not be using date display values on server side - it just complicates things while adding nothing to the outcome. If you insist, you should on one hand use .getDisplayValueInternal() instead on the other hand use it throughout. It returns the date and time value in the system format.
All that also means you can't use new GlideDateTime (inquiryDate);: it expects inquiryDate to be the date and time in the system TZ (UTC by default), but it will most likely not be as the value has been obtained using a display value method - which returns the date and time in the current user's TZ.
That is why, just don't use the display value methods on server side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2021 05:11 AM
Thank you Janos. This helps explain things for me and will be useful to come back to in the future!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2021 05:24 AM
You're most welcome 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2021 12:37 PM
Try the below. It should be doing everything in GMT.
Also why do you care if its open before you use the resolution date? Why not just check if it has a value and if it does then use it?
(function executeRule(current, previous /*null when async*/) {
if(current.u_inquiry_date){
var startDate = current.u_inquiry_date.getGlideObject();
var endDate = new GlideDateTime();
if(current.getValue('u_state') != 'Open' && current.u_resolution_date){
endDate = current.u_resolution_date.getGlideObject();
}
var dur = endDate.getNumericValue() - startDate.getNumericValue();
//convert the answer from milliseconds to days
var days = dur / (1000*60*60*24);
if(days < 1){
days = 1;
}
current.u_resolution_time = days;
} else {
current.u_resolution_time = 0;
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2021 05:08 AM
Hi Drew,
This (combined with Janos' response) helped me immensely! Thank you so much!
-Matt