- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 04:06 AM - edited 11-06-2023 04:10 AM
HI,
When we set the state to on hold and on hold reason field to any one option, then we want to populate the date/time on "On Release" field level.
During the process, when we change the on hold reason field to any other options without changing the state from on hold then we don't want to change the populated date/time.
And the populated the time should change only when we change the state from on hold.
We wrote the below business rule to run when state changes to on hold and it's working fine.
Now the requirement is we don't want to populate date/time when the "on hold reason" field option is either A or C.
Can anyone please help us to adjust the below script to skip the date/time.
(function executeRule(current, previous /*null when async*/ ) {
//functionality configurations
var tz = "America/New_York";
var hours = 48;
var rightNow = new GlideDateTime();
var dur = new GlideDuration(3600000 * hours);
var schedule = new GlideSchedule('021479371bdb99d04649c845604bcb58', tz);
var releaseDT = schedule.add(rightNow, dur);
current.u_hold_release = releaseDT;
})(current, previous);
Thanks,
LARA REDDY
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 02:04 AM
HI Lara,
Hope the below script helps you.
AR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 04:49 AM
you need to ensure your BR doesn't run for the case you wish to skip it
Handle this using BR conditions
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 04:53 AM
Thanks for the response Ankur.
We are able to skip to populating the date/time on On Reason field level.
We're facing only one below issue:
Example:
1. State is On hold && on hold reason is B = 2023-11-08 04:35:25 [date/time is populated]
2. State is still same && on hold reason is changed to A == On Reason field populated date/time is cleared
3. And now still state is same and on hold reason is changes to B or D == We need to set the first populated date/time [2023-11-08 04:35:25] again because we're not changed the state from on hold.
I hope you got my requirement/issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 05:35 AM
unless you track in some field when was the 1st time the value was populated and when it got changed, you won't be able to know
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 04:09 AM
Hi Ankur,
We tried using to capture the populated date/time in one variable and using the same date/time to populate again when on on hold reason is changes to B or D from A.
The only issue we are facing now is
1. State is on hold and on hold reason is A ---> date/time will not populate. [It's working fine]
2. state is same and on hold reason B or D ---> the new date/time is not populating [As per the process it should populate new date/time but it's not populating and it's goes under error :one ].
Please check the below script once:
Advance thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 02:04 AM
HI Lara,
Hope the below script helps you.
AR