How can we convert the value of "Duration" field in SLA to hours
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 06:16 PM
Hi All,
We have a requirement to create two custom fields in task_sla table record.
-> First field - Duration in hours ( We need to get the value of this field as the hours format of the "SLA Definition duration" field value. eg:- if duration is 2 days, then value of this field needs should be reflected as 24 hours)
-> Second Field - 5X VSL - (We need to get the value of this field as the multiplication of "Duration in hours" field *5. eg:- if "Duration in hours" is 24 then 5X VSL should be reflected as 120 hours.)
Can anyone please help me on this ASAP?
Thanks in advance.
Regards
Aswathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 08:20 PM
Hi, it sounds like you need a simple beforeInsert BR on task_sla.
Take the duration field which is stored as a epoc offest, convert to ticks\milliseconds and divide to get hours, set this as first field, multiply this by 5 and round to get second field.
gs.info(current.duration);
var gdt = new GlideDateTime(current.duration);
var unixTime = gdt.getNumericValue();
var slaHours = unixTime /1000/60/60;
var x5Hours = parseInt(slaHours * 5);
//Without the rounding from parseInt
//var x5Hours = slaHours * 5;
gs.info(slaHours);
gs.info(x5Hours);
current.u_fieldOne = slaHours;
current.u_fieldTwo = x5Hours;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 05:23 PM
Hi Tony,
The value of "Duration" actually we are looking the SLA definition duration and directly the value is not getting in TASK SLA form.
How can we get that data using script to get the duration in hours and 5X.
Thanks
Aswathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 09:02 PM
Did you try dot.walking through the task_sla record and into the definitions duration field?
var gdt = new GlideDateTime(current.sla.duration);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 10:33 PM
Hi Tony,
I have tied with dot.walking code and it is still not working as expected.
Regards
Aswathy