Delay processing of business rule

etabalon
Mega Expert

Is there some kind of function or code that I can use to delay the processing of a business rule?

By default, once a record is updated and the BR condition is met, the script runs immediately.

What I want to do is delay the running of the script for at least 15 seconds.

This BR sends the ticket info to another system (web service/SOAP).

Thank you!
Enrique

 

1 ACCEPTED SOLUTION

Elijah Aromola
Mega Sage

There is a method available in global apps called gs.sleep() where you pass the number of milliseconds you want it to wait. You can also write your own method and call it using something like:

//available in global scope
gs.sleep(5000); //5 seconds


// Custom function if you can't use gs.sleep
function pause(time){  
  var t1 = new GlideDateTime().getNumericValue();  
  var t2 = new GlideDateTime().getNumericValue();  
  var duration = t2 - t1;  
  while(duration < time){  
      t2 = new GlideDateTime().getNumericValue();  
      duration = t2 - t1;  
  }  
},

Both of these would have an impact on your system since you are calling it on the server. Is there any reason you're unable to send it right away?

Please mark my answer as helpful/correct if it resolved your issue!

View solution in original post

5 REPLIES 5

Async BR solved my problem as well. I wanted to update an SC Task created by "Hardware Inventory Stock Order" catalog item. This catalog item creates a request, a requested item and a sc task. Interestingly the parent of this sc task is the request and not the requested item.