How to call a scheduled job from scoped application?

asit_vachhani
Giga Contributor

I am trying to call scheduled job from my UI action in my scoped application. But it gives me an error saying "SncTriggerSynchronizer is not allowed in scoped applications".

Can anyone please tell me how I can overcome this error?

Thanks

6 REPLIES 6

bernyalvarado
Mega Sage

Hi Asit,



Have you considered adding your call to the scheduled job from a Script Include which is marked as Accessible from All Application Scopes. Refer to section 3.1 on the below link.



Scripting in Scoped Applications - ServiceNow Wiki



I hope this helps.



Thanks,


Berny


Hey Berny,



Thanks for the response, I did try that but it didn't work. Making my script include public or private will reflect on the script include itself. If I make my script include public, I can use that script from any other application, that does not mean I can trigger scheduled job, since that is still private and it has the restricted access. When I tried your suggested approach, all the script above my SncTriggerSynchronizer.executeNow(rec) runs perfectly but not anything after this function.



Thanks,


Asit


bernyalvarado
Mega Sage

Hi Asit,



I hope you're doing well!



Do you have any further questions? If not, do you believe you can mark the response as correct so that we can close this thread?



Thanks,


Berny


tlsimmons
Tera Contributor

Hi Asit,



Here is how you can do what you want:



//Global scope


SncTriggerSynchronizer.executeNow(rec);


//Scoped app


gs.executeNow(rec);