How to set Business Duration field on RITM?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2025 05:49 AM
I'm not able to set business duration field on old ritms and i have used below codes.
var grRITM = new GlideRecord('sc_req_item');
grRITM.addEncodedQuery("number=RITM18884753^business_duration=javascript:gs.getDurationDate('0 0:0:0')");
grRITM.query();
if (grRITM.next()) {
var opened = grRITM.opened_at.getValue();
var closed = grRITM.closed_at.getValue();
if (grRITM.business_duration == '') {
grRITM.business_duration = gs.calDateDiff(opened, closed, false);
grRITM.update();
}
}
Is there any alternative method for calDateDiff.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2025 08:00 AM
Hello @damodharan1
Please take another incident as example, because see the opened timing and resolved timing is completely same it's hardly 20 seconds difference - so what would the business duration be ?
The business duration field only stores values in days, Hours and minutes not seconds.
Please try on an existing incident, don't create a new incident and resolve it. I am sure this will work, refer my screenshot, it's live example.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2025 08:19 AM
Hello Shivalika
Even for other incidents it was same result and not sure why its not working.
Regards,
Damodharan
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2025 08:23 AM
Hello @damodharan1
I am not understanding why are you taking incidents which have barely few seconds to few minutes of difference ? In that time - business duration - how will it calculate - what if it wasn't even in the business days?
please check on your table with incidents which are having some nice difference like I showed it gave me 5 Days and Few hours and minutes. Select some nice incidents and check this.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2025 08:07 AM
you want to find difference between opened and closed using some schedule?
if yes then which schedule it is? your script didn't mention anything about schedule
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2025 06:16 AM
Hello @damodharan1
I can see the wrong format used to get the Values. Use below to correct :
If this solution helped resolve your issue, please consider marking it as helpful or correct.
This will assist others in finding the solution faster and close the thread.