- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 07:26 AM
Hello,
I was wondering what is best to use a Script Include or a Script Action? Here is the problem I had and how I'm trying to solve it:
1- I had a workflow with a 'Run Script' activity where I was creating new requested items in a request. The 'Run Script' activity was triggered when a catalog task was manually closed by a user. The creation of the new requested items could take some time and so the user's browser was hanging until the ceration was done (not a great experience).
2- I then thought, instead of putting my code in the workflow 'Run Script' activity I would call a Script Include having all the code to create the requested items. It worked but here again the user's browser was hanging.
3- After searching a bit, I came up with generating an Event in the workflow and then process the event (and parameters) by a Script Action and calling my Script Include.
Now I'm wondering, do I really need to call my Script Include to process all the code to create the requested items or can I just put the code in the Script Action? Is there one more performant than to other?
Thank you
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 07:53 AM
You can leave your code in the script include and call that from the script action. Script includes make your code reusable they're not necessarily more performant or less. I think what you're running into is when you use the run script activity to call a script include it sounds like everything is running synchronously so it holds up the session for the user. If you go event > script action > script include that whole process happens asynchronously and doesn't lock up the user session since the event if kicked off into the event queue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 07:48 AM
Hi Sergio,
You can go ahead and use Script Action since it will run in background only when system processes the event. This will not be causing any issue to the user. Script Actions are generally used for heavy background script.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 07:53 AM
You can leave your code in the script include and call that from the script action. Script includes make your code reusable they're not necessarily more performant or less. I think what you're running into is when you use the run script activity to call a script include it sounds like everything is running synchronously so it holds up the session for the user. If you go event > script action > script include that whole process happens asynchronously and doesn't lock up the user session since the event if kicked off into the event queue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 12:44 AM
Hello,
You can find the detailed explanation of the script action in the below link:-
https://servicenowspectaculars.com/what-is-servicenow-script-action/