- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2016 09:41 PM
I have a script that I want to run.
This script deploys some functionality. It is effectively an "install script",
but it's a little bit metamorphic because it customizes the install to the user's instance and usage.
It's about a thousand lines, but it installs something closer to like 100k lines (intelligently; not haphazardly), so obviously the usual methods of installing an app or loading an update set aren't... at least as far as I know... a viable option.
Let's say it's: "doInstall();"
Is there any way to package this script in such a way, that I can easily deploy it into an instance? Something like an update set that would deploy and then execute (only once) a script include?
I can put it into an update set as a script include, but I'm not sure how to actually invoke the script to do the install.
Any pro-tips for me?
EDIT: Whether it's a pre-packaged "install script" or some way to simply execute a script after installing an update set, it would be useful to know how to do this.
I have tried adding a scheduled script execution to an update set, then manipulating the update set XML so that its' "run_start" value is "javascript:gs.minutesAgo(-3)", but that doesn't seem to work. It doesn't accept that value.
Perhaps there's some way to execute a script inside of an update set prior to deploying it?
Anything like that, or any point in the right direction would be extremely useful.
Message was edited by: Timothy Woodruff
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2016 04:42 PM
In case anyone happens across this article, I found a way to do it. I packaged it into this app: SN Pro Tips — Update Set Collision Avoidance
You can download that to see how it works, in case you need an example to work off of.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2016 09:53 PM
Yes, there is a concept called Fix Scripts in Servicenow, those scripts can be made to run once after upgrade or cloning -
For more information, refer the below wiki article -
Run once | Select the check box to run the script only one time (default). The fix script is ignored for subsequent upgrades. Clear the check box allow the script to run every time the application is installed or upgraded. This option is enforced by the following mechanism.
Run once is not enforced when you test the fix script. |
Mark if it is helpful or correct, feedback is appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2016 10:54 PM
So would you say I'd just install an application where the only thing in it is this fix script?
Would the code have the same limitations as scoped apps?
(I've never built an app before except through the developer site tutorial)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2016 12:50 AM
Yes, if the new application is built in its own scope, then there will be restriction in accessing the tables belonging to other applications in different scope.
Make sure the tables what you will be accessing in the fix script will have property enabled in their table configuration tab in such a way, the application belonging to other scope can access it
Hopefully it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2016 11:35 AM
Thanks Srikanth; however, this is exactly one of the things that I want to avoid. My script needs to run in the global scope. Are you aware of anything that would make that possible?