Getting the wrong Business Duration value on RITM table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 12:06 AM
Hi
Getting the wrong Business Duration value(Mostly getting 0 value or Garbage value) on RITM table even I used the code same as incident mark_closed BR however on incident table have the same wrong data below is the code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 12:18 AM
@raj99918 Try to use getValue instead of getdisplayvalue, this should work please find below refined code:
(function executeRule(current, previous /*null when async*/ ) {
var opened = current.opened_at.getValue();
var closed = current.closed_at.getValue();
if (opened && closed) { // Ensure both fields have values
if (current.business_duration.nil())
current.business_duration = gs.calDateDiff(opened, closed, false); // Business Duration
if (current.calendar_duration.nil())
current.calendar_duration = gs.dateDiff(opened, closed, false); // Duration
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 12:25 AM
Hi @Abhay Kumar1 Thanks for the reply but just want to ask onething even OOB BR have the same getdisplayvalue May I know the reason for this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 01:28 AM
@raj99918 getDisplayValue() retrieves the date in the user's display format, which may differ from the system format. Using getValue() may avoid formatting issues if dates are being interpreted incorrectly. This is the reason I had suggested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 05:59 AM
this is OOB BR.
So are you saying it's not working as expected?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader