Passing data to Scheduled Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 08:17 AM
Hi
I am triggering a Scheduled Script from a UI Action using SncTriggerSynchronizer.executeNow.
Is it possible to pass data to the Scheduled Script ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2015 08:49 PM
Jacques Canuel - Hi Jack - Were you able to resolve this?
All - Has anyone accomplished this? I want to pass a parameter to scheduled job while triggering it from a script. I am aware of SncTriggerSynchronizer but not sure how to pass the parameter.
Any help will be appreciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2015 09:24 PM
Could I suggest that you use an event to trigger a UI Script.
This way you can parse parameters to your script.
- Navigate to "System Policy > Events > Registry"
- Click 'New'
- Create your event record (let's say "event.test")
- Add the following code to your Server Side UI Action
var parm1 = "Whatever you want";
var parm2 = "Something else";
gs.eventQueue("event.test", current, parm1, parm2); - Navigate to "System Policy > Events > Script Actions"
- Click 'New'
- Set event to "event.test"
- Write your script in 'Script'
- Use variables 'parm1' and 'parm2' to refer to your parameters
Script Actions - ServiceNow Wiki
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2015 09:34 PM
Paul Morris - Thanks for your reply. I am aware of this approach. However, I want to run a "scheduled job" with the params. Especially use the feature of running the script as a particular user.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2015 09:43 PM
Unfortunately I can't see any other way to do it.
If you want to a script to execute as a user, you could impersonate the user via the gs.getSession().impersonate(parm1), where parm1 is gs.getUserID() from the calling business rule.
If you didn't have a requirement to parse in parameters you could also use
fcRunAs=user
fcScriptName=incident autoclose
to run the the scheduled job as a user, where the script is a business rule.
Closing Resolved Incidents Automatically - ServiceNow Wiki
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022