- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 08:20 PM
I am trying to calculate a duration field "legal_review_duration" using 2 date/time fields "legal_hold_start" and "legal_hold_end". I created a business rule with the following script.
-------------------------------------------
----------------------------------------------
When I try to test it, I am getting this error:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 08:49 PM
you should use GlideDateTime.subtract() in scoped app as dateDiff() is not supported
something like this in before update business rule
var start = new GlideDateTime(current.legal_hold_start);
var stop = new GlideDateTime(current.legal_hold_end);
var duration = GlideDateTime.subtract(start, stop);
current.legal_review_duration = duration;
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
06-10-2025 08:49 PM
you should use GlideDateTime.subtract() in scoped app as dateDiff() is not supported
something like this in before update business rule
var start = new GlideDateTime(current.legal_hold_start);
var stop = new GlideDateTime(current.legal_hold_end);
var duration = GlideDateTime.subtract(start, stop);
current.legal_review_duration = duration;
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