Has anyone implemeted or configured script action, please help me with Scenario
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Has anyone implemeted or configured script action, please help me with Scenario
_ want to know how it is configured and how it works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
It's simple
-> create event with or without table
-> have script action with your script and linked to above event
-> ensure you trigger your event created in step 1 using gs.eventQueue() or gs.eventQueueScheduled()
-> once the event is processed the script action will run it's script as it's listening to that event
Script Action: A Practical Example!
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
HI @Vivek Bakare ,
Yes. If you mean a Script Action in Flow Designer/Workflow Studio, it is basically a reusable custom Action containing a Script step. It is useful when the OOB Flow Designer actions cannot perform the logic you need. ServiceNow's current documentation describes the Script step as server-side JavaScript with separate inputs and outputs.
Simple example scenario
Suppose you have a Flow triggered when an Incident is created, and you want to calculate a value based on the Incident priority.
For example:
If Priority = 1 → return "Critical"
If Priority = 2 → return "High"
Otherwise → return "Normal"
You could create a reusable custom Action called Calculate Incident Severity.
How it works
Flow → Custom Action → Script Step → Output → Next Flow Action
1. Create the Action
Go to:
Workflow Studio → Actions → New
Create:
Action name: Calculate Incident Severity
Add an input:
- Label: Incident
- Name: incident
- Type: Reference
- Reference table: Incident [incident]
Then create an output:
- Label: Severity
- Name: severity
- Type: String
ServiceNow allows Action inputs to receive dynamic data pills from the Flow, while outputs become available as data pills for subsequent steps.
2. Add a Script step
Add:
Action Outline → Steps → Add → Script
The script can be:
The important part is:
This receives the value passed into the Action.
And:
returns the result to the Flow.
This input/output model is the standard way Script steps communicate with the rest of Workflow Studio.
3. Use the Action in your Flow
Your Flow could look like:
Trigger: Incident → Created
↓
Calculate Incident Severity
Input:
Incident → Trigger → Incident
↓
Update Record
Set:
Severity → Calculate Incident Severity → Severity
So instead of putting the JavaScript directly into every Flow, you now have a reusable Action.
When should you use a Script Action?
I would use one when:
- OOB Flow actions don't provide the required logic.
- You need complex GlideRecord processing.
- The same logic will be reused in multiple Flows.
- You need to return calculated values to the Flow.
For very small transformations, ServiceNow recommends using inline scripts or transform functions instead of creating a custom Action. For reusable or complex logic, a custom Action/Subflow is generally more appropriate.
Also, test the Action independently before using it in the Flow. Workflow Studio provides an Action Test option and execution details so you can verify the input and output values.
If you're learning ServiceNow, this is actually a good exercise to understand Flow Designer + Action Inputs + Script Step + Action Outputs together.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @Vivek Bakare,
Script Action is run when an event is triggered. You can create an event, use it in your Script Action, trigger the event and run the script action.
Sharing a video I found useful.
https://www.youtube.com/watch?v=M3PXXMYv2JQ&pp=ygUYc2NyaXB0IGFjdGlvbiBzZXJ2aWNlbm93
Please Accept this response as Solution if it assisted you with your question & Mark this response as Helpful.
Kind Regards,
Ehab Pilloor