- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 06:23 AM
Hi Folks,
I am getting difference of two dates and the trying to add that to a date/time field, but with no luck . I am able to get the difference but that is not getting added to the field. Below is my code
var cas1 = new GlideRecord('sn_customerservice_case');
cas1.get('db53532e47e251106b801c65d36d4307');
var resolved_at = new GlideDateTime(cas1.resolved_at);
var rejection = new GlideDateTime(cas1.u_rejection_time);
var dur2 = GlideDateTime.subtract(resolved_at,rejection);
var num_value = dur2.getNumericValue();
var sla = new GlideRecord('task_sla');
sla.addQuery('task',cas1.sys_id);
sla.query();
if(sla.next()){
var breach = new GlideDateTime(sla.planned_end_time);
var new_breach = breach.add(num_value);
gs.print(new_breach);
}
new_breach returns undefined
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 06:57 AM
The add() method on GlideDateTime does not return a value, which is the reason why "new_breach" returns undefined. In this case, when you call the add() method against the "breach" variable it is mutating the value of "breach". I hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 06:57 AM
The add() method on GlideDateTime does not return a value, which is the reason why "new_breach" returns undefined. In this case, when you call the add() method against the "breach" variable it is mutating the value of "breach". I hope this helps!