Trigger Scheduled Job from Business Rule

MKM
Mega Expert

How do I trigger a scheduled job from the business rule and send the values from the business rule to the scheduled job that is being triggered?

Currently, I am using this to trigger the Scheduled job, but I want to also send values to the scheduled job from the business rule.

find_real_file.png

10 REPLIES 10

Ankur Swami
Tera Guru

Hi,

 

Write below script in the advanced area of the BR to trigger the SJ.

 

var schImp_GR = new GlideRecord('sysauto');
schImp_GR.addQuery('name','<name>'); // Name of the scheduled job
schImp_GR.query();
if(schImp_GR.next()){
SncTriggerSynchronizer.executeNow(schImp_GR); // this is for global scope
}

Hi Ankur,

Thanks for your response. I am able to run the scheduled job but how will I get the current values from the business rule into the scheduled job.

 

 

hi,

You can write like below:

 

SncTriggerSynchronizer.executeNow(current);

I am not sure what you are going to implement in Scheduled Job. But the way i suggest will work.

 

For better understanding can you please explain what functionality you are going to implement in SJ from the current object of BR.

May be after getting the better understanding i can help you with some better stuff.

Hi Ankur,

The scenario is, we have two catalog items. Based on the approval of Cat item 1, the Cat item 2 should be created by using the values of what we have in Cat item 1. I wrote a BR to submit a Cat item 2 after approval of Cat item 1.

But the problem is the system is creating the Cat item 2 in the name of the person whose approval is triggering this business rule.  I want that to be changed for which I will be using the "Run As" field on the scheduled job.