- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 12:43 PM
I need to create a business rule to reject the change if it it not approved by the planned start date/time. I have written the following business rule but it isn't working. I'm new to scripting any help would be great. Thank you!
When to run: After Update
Condition: current.state == 'requested'
RejectPlannedDate (); |
function RejectPlannedDate ()
{
var approval = new GlideRecord("sysapproval_appover");
approval.addQuery('start_date' , '>=' , gs.current.start_date);
approval.query();
if (approval.next())
{
approval.state = 'rejected';
approval.update();
gs.addInfoMessage(gs.getMessage('Change rejected due to lack of approval by planned start date/time'));
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 01:33 PM
Not a "Wait for", but use a "Timer" activity instead and set the "Timer Based on" to "a date/time or duration field" and then select Planned Start Date as the field.
and then branch an activity off of that timer to reject the change automatically. That way, as soon as start_date is reached, the timer will kick off and expire the change if it is not already approved (you do need to make sure you check that the change is not already fully approved at that point). I would also reconsider setting the approval records as rejected. this may cause confusion where it may look like someone actually rejected when they didn't. instead, you could set the phase state to something that won't allow the change to progress until it is rescheduled.
this is exactly the solution we have done at my current company and works like a charm.
Jon
ps: if you want the change to show rejected exactly at the start_date if not fully approved, then a business rule would not give you that ability. Workflow or scheduled job is best, but scheduled job may be delayed as well, workflow is probably the best option for you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 02:24 PM
Yup, I totally get that
-Jon
Sent from my iPhone

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 12:56 PM
Hi Danielle,
When I was a customer, I did this with a schedule job that ran every hour (or day) - it was several years ago. It triggered notifications and then set the approvals to rejected as necessary. I don't still have the original code, but it's not hard to search through the active approvals in sysapproval_approvers and set the state on the old ones.
I've also seen several solutions on the community that have done it with workflows. Here's one that came up.
Your searching may find others. Good luck.