How to trigger a scheduled job from a business rule

johannes5
Giga Expert

Hi ServiceNow Community Developers,

Do you know if there is a way to trigger a scheduled job from a business rule. The input to the scheduled job would be the serial number so I would like to pass that along from a business rule. Please advise.

Thanks,

Johannes

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Johannes,



This is an interesting question, and not a typical one at that. Scheduled jobs are normally set to run at a specific time, interval, etc. Business rules run based on a database trigger. They are two different use cases in my mind. What's more, scheduled jobs don't take parameters. It sounds like you might need a script include or something else instead.



Can you tell me more about what you are trying to accomplish? I'd like to understand better what your requirement so I can offer an appropriate solution or options.


View solution in original post

17 REPLIES 17

Gangadhar Ravi
Giga Sage
Giga Sage

You can use some thing like bellow but is not a best practice to do this using a business rule. As suggested by Chuck and pradeep please provide more details.



var rec = new GlideRecord('sysauto_script');


rec.get('name', 'YOUR_JOB_NAME_HERE');


SncTriggerSynchronizer.executeNow(rec);



Thanks,


Ganga.


Hi Guys,



Do you know if I can use callback functions in a script include?   Please advise.



Thanks,


Johannes


Hi Johannes,



Callback functions are usually used for async operations. It would really help us if you provided some detail around what your requirements are so we can understand the context.



http://xyproblem.info/


Chuck,



I like the XY reference.   I've never seen that before, but very true in everything. (Just yesterday another user asked me to get a "disc with the OS for Microsoft Word" to reinstall when his laptop died... )




-Brian


Thanks. One of our developers passed that along. I absolutely love it when it comes to understanding requirements. I'm as guilty as anyone of abusing it. "Do we have a way to do ABC in ServiceNow?" And someone will throw that back in my face. We all think we know what the solution should be and when we get in trouble we ask for help on that solution, but there may be another (better) way to solve the requirement that we haven't thought of.



That's what makes this community so great!