Hold The Business Rule for 15 mins

AbdulNow
Tera Guru

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!   

1 ACCEPTED SOLUTION

Lukasz Bojara
Kilo Sage

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:

find_real_file.png

 

Next step is to create Script Action to handle the event:

find_real_file.png

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:

find_real_file.png

 

After the time the event will be processed and Script Action will create an Incident.

find_real_file.png

find_real_file.png

Hope this helped.

 

Best regards,
Łukasz

 

View solution in original post

6 REPLIES 6

AbhishekGardade
Giga Sage

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

Thank you,
Abhishek Gardade

Chris M3
Tera Guru

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. 

 

Oh, man. This brings back memories!


I'd do it totally different this time around.... Like most things you look at two years later.

 

 

Lukasz Bojara
Kilo Sage

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:

find_real_file.png

 

Next step is to create Script Action to handle the event:

find_real_file.png

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:

find_real_file.png

 

After the time the event will be processed and Script Action will create an Incident.

find_real_file.png

find_real_file.png

Hope this helped.

 

Best regards,
Łukasz