- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 03:59 AM
Hello All,
Can anyone please help me how to acheive this.
i need to store diierence of actual end and actual start field value in total onhold time.
It is giving 1 hour 10minutes and 06 second.But it should give only 10 min 06 second.
Can anyone please help me how to get this correct value.
below is the before business rule i wrote.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 10:50 PM - edited 09-21-2024 10:54 PM
Hi @Mansi roy ,
Fields with data type - Time will append 1970-01-01 before the time value in UTC.
Ex: let us consider Actual Start : 11:38:19, it'll be 1970-01-01 06:08:19 (you can find this in XML).
if you want to set value to time field you've to use this format.
I made modifications to your code, It should work as desired.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var actualStart = current.u_start;
var actualEnd = current.u_end;
// gs.info('Actual Start'+actualStart +'Actual End'+actualEnd);
var gdt1 = new GlideDateTime(actualStart);
var gdt2 = new GlideDateTime(actualEnd);
var diffIs = gs.dateDiff(gdt1,gdt2);
gs.addErrorMessage(diffIs);
var gdt= new GlideDateTime('1970-01-01 '+diffIs);
gdt.addSeconds(gdt.getTZOffset()/-1000);
gs.addErrorMessage(gdt);
current.u_time_diff= gdt;
// current.update();
})(current, previous);
Mark my response as helpful 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 10:50 PM - edited 09-21-2024 10:54 PM
Hi @Mansi roy ,
Fields with data type - Time will append 1970-01-01 before the time value in UTC.
Ex: let us consider Actual Start : 11:38:19, it'll be 1970-01-01 06:08:19 (you can find this in XML).
if you want to set value to time field you've to use this format.
I made modifications to your code, It should work as desired.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var actualStart = current.u_start;
var actualEnd = current.u_end;
// gs.info('Actual Start'+actualStart +'Actual End'+actualEnd);
var gdt1 = new GlideDateTime(actualStart);
var gdt2 = new GlideDateTime(actualEnd);
var diffIs = gs.dateDiff(gdt1,gdt2);
gs.addErrorMessage(diffIs);
var gdt= new GlideDateTime('1970-01-01 '+diffIs);
gdt.addSeconds(gdt.getTZOffset()/-1000);
gs.addErrorMessage(gdt);
current.u_time_diff= gdt;
// current.update();
})(current, previous);
Mark my response as helpful 🙂
