Automatically set the difference between actual start date and actual end date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 09:34 AM
Hello experts
I am needing help with populatig dirrence between actual start and actual end date in the duration field on in the outage form
when the "actual start date" and actual end date fields are populated on the change form, then the duration field should automatically be set to the difference between the actual end date and the actual start date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 09:45 AM
Hello Nath,
Store the Start and End Date in var:
var actualStartDate = g_form.getValue('actual_start_date');
var actualEndDate = g_form.getValue('actual_end_date');
Get the difference between:
var startTime = new GlideDateTime(actualStartDate);
var endTime = new GlideDateTime(actualEndDate);
var duration = endTime.getDifference(startTime);
Set duration:
g_form.setValue('duration', duration / 1000 / 60);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 10:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 08:09 PM
No, GlideDateTime will not work client side.
You will have ise to GlideAjax and Script Includes.
Do the calculation part in script include and return the difference to the client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 08:18 PM
Hi @nath0507 ,
if you are looking for exact scripts, you can go through this community article which might help.
Mark helpful if it helps in solving your query,
Regards,
Johns