- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 10:35 AM
Hello Experts,
We want to calculate the request or change created between approval approved days calculation.
this is totally new requirement for us.
created new field on the approval table.
field name - "Open days"
field type - Date/time.
Requirement .
How to achieve the calculation created b/w approved kindly support.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 11:05 AM
Hi @akin9 ,
You need to create the custom field with the type as "Duration" in order to store the duration between approval created, action taken and update this field from a after business rule. I have implemented the solution in my PDI, attached the below screenshots for your reference.
Let me know in case if you have any further queries.
If the solution shared works for you, please "Accept as Solution" and mark " Helpful."
Thanks,
Gummagatta Harshavardhana
Dictionary Entry -
Business rule condition -
Business rule script -
.
var gdt1 = GlideDateTime(current.getValue('sys_created_on')); // get the request opened date and time
var gdt2 = GlideDateTime(current.getValue('sys_updated_on')); // get the request closed date and time
var duration = gs.dateDiff(gdt1.getDisplayValue(), gdt2.getDisplayValue(), false); // Calculate the difference bewtween opened and approved time
var grAppr = new GlideRecord('sysapproval_approver');
grAppr.addQuery('sys_id', current.getUniqueValue());
grAppr.query();
if (grAppr.next()) {
grAppr.u_approval_duration = duration; // update the duration field with the difference
grAppr.update();
}
Output -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 11:05 AM
Hi @akin9 ,
You need to create the custom field with the type as "Duration" in order to store the duration between approval created, action taken and update this field from a after business rule. I have implemented the solution in my PDI, attached the below screenshots for your reference.
Let me know in case if you have any further queries.
If the solution shared works for you, please "Accept as Solution" and mark " Helpful."
Thanks,
Gummagatta Harshavardhana
Dictionary Entry -
Business rule condition -
Business rule script -
.
var gdt1 = GlideDateTime(current.getValue('sys_created_on')); // get the request opened date and time
var gdt2 = GlideDateTime(current.getValue('sys_updated_on')); // get the request closed date and time
var duration = gs.dateDiff(gdt1.getDisplayValue(), gdt2.getDisplayValue(), false); // Calculate the difference bewtween opened and approved time
var grAppr = new GlideRecord('sysapproval_approver');
grAppr.addQuery('sys_id', current.getUniqueValue());
grAppr.query();
if (grAppr.next()) {
grAppr.u_approval_duration = duration; // update the duration field with the difference
grAppr.update();
}
Output -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 12:04 PM
Hi @Gummagatta Hars ,
Thanks for the Quick reply !
Its working fine and one more question
Days will calculate 24hrs?
2.Can we use this on reports as well? Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 12:16 PM
Hi @akin9 ,
Yes a day will be 24 hours and this field can be used in reports.
Let me know in case if you have any further queries.
If the solution shared works for you, please "Accept as Solution" and mark " Helpful."
Thanks,
Gummagatta Harshavardhana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 12:25 PM