- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2021 03:55 AM
I have one duration field so I converted it to seconds using attribute set to seconds. This value is milliseconds and so to get value I used: (time_left is the duration field value)
var Duration = (current.time_left.getGlideObject().getNumericValue() / 1000); // multiple by .001 or divide by 1000
Now In duration I have days, hours, minutes in complete seconds .
So I have date field now which needs to be converted to seconds again: on_hold_till is the date field value
I have this code:
var gdt = new GlideDateTime();
gdt.setValue(current.getValue('on_hold_till'));
var ms = gdt.getNumerciValue();
Now in var Duration I have duration in seconds and now in Var ms I have date field in seconds.
So now I have to add this and set this to a new field. ( I want duration to add to a date field to get a new date field):
like adding both this seconds and then converting totals seconds to a date field.
Any help on this!!!!! Please
If you have easy way to add duration to date feel free to provide using the above field values.
TIA
Solved! Go to Solution.
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2021 10:26 PM
Hi,
do this
// to get duration time to seconds.
var startTime = new GlideDateTime(current.u_date.getDisplayValue());
var duration = current.time_left.dateNumericValue();
startTime.add(duration);
current.u_target_date = startTime.getDate();
// OR if u_target_date is of type date/time then do this
current.u_target_date = startTime.getDisplayValue();
current.update();
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
06-10-2021 08:10 AM
The above BR is a different scenario and the one you help me and working is different. This BR is in scoped application and not working. as my previous BR worked when set to global so I tried this BR as well in Global but no use.
Breach Time is in SLA definition and target date is in case form .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2021 01:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2021 02:02 AM
Glad to know that my script worked.
Now you need to debug why that BR didn't trigger.
Did it satisfy the condition?
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader