- 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
09-12-2019 05:30 AM
You can use gs.sleep() method. Why you are holding a business rule for 15 Minutes? Instead make use of eventQueueSchedule and using script action run it
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2019 06:19 AM
Trigger a delayed event using gs.eventQueueScheduled, you can find details of it in the API Documentation.
Basically when mid server goes down, queue up an event for 15 minutes later. Then have a Script action based off that event. Check the status of the midserver when you process the event. If up, all good, if still down open an Incident.
Another way would be to trigger a workflow. Again, start it when down, wait 15 minutes with a timer and maybe a wait for condition for status to switch to up, and then trigger an incident accordingly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2019 09:39 AM
Oh, man. This brings back memories!
I'd do it totally different this time around.... Like most things you look at two years later.

- 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