- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2019 05:12 AM
I have a requirement if we mid Sever is down , We have to create a incident but one condition as After 15 mins and if mid sever is up within 15 mins then no action required .
I'm trying to achieve by BR and adding gs.Sleep() but it is not working and also making instance very slow.
Please Help Guys .. Much Appreciate!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2019 07:17 AM
Hi,
What you could do is register your own event and delay its processing. Then you will set up a Script Action on that to create incident.
For example (I have used Change Request) register new event:
Next step is to create Script Action to handle the event:
When you will have those 2, the last part is to create a Business Rule that will react when a value changes (for me when change request is cancelled) and in Advance write somethin like this:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var whenTrigger = new GlideDateTime(); // get current datetime
whenTrigger.addSeconds(180); // add 3 minutes
gs.eventQueueScheduled('test.scheduled.event',current,current.number,'Scheduled on ' + whenTrigger.getDisplayValue(),whenTrigger);
})(current, previous);
When BR will fire the event you will see in logs that it is deleyed:
After the time the event will be processed and Script Action will create an Incident.
Hope this helped.
Best regards,
Łukasz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 09:25 AM
Hello Łukasz,
What's the value for 'When' in When to Run tab for Business Rule? Should it be before, after, async or display?
It's all up and running, but it's creating 2 incidents. 1 incident is created right after the CR is cancelled. Another incident is created after the 'whenTrigger', which is in 3minutes.
Regards,
Neal Castro

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2020 12:28 AM
Hello neallor,
Business Rules run when specific database operations are performed e.g. INSERT or UPDATE. The When setting provides information on a time when Business Rule should be triggered so if you will set it e.g. to Before and database operation will be INSERT then it means that Business Rule will be triggered before this operation, so first everything that BR is doing will be done and then the new record will be inserted. There are some best practises around using it, e.g. if you want to modify current record before it will be saved to the database you should set it to Before, if you want to update other record based on changes made to the current one then you should set it to After.
There is one very important rule that you should always follow: never use current.update() in Business Rules. This will trigger the BR once again and you will end up with an infinite loop of BRs.
As for your second note. Check if there is no other mechanism that creates this first incident. Also if you would show how you have set up your solution it would be easier to see what went wrong.
If my answer helped you in any way, please then mark it as helpful. If this solved your case please mark it as a correct answer. Thank You.
Best regards,
Łukasz