How to create an incident in flow designer with script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 02:44 AM - edited 01-05-2024 02:47 AM
Hi,
I am trying to create an incident using Flow Designer via scripting. Can you please show me how it can be done? Kindly help.
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 02:49 AM
Hi @Community Alums
https://www.youtube.com/watch?v=KZpZDqbRKU4
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 02:52 AM
Hi @Community Alums ,
To create an incident from the flow (Flow designer) you don't need to create it via script. In the actions space, Click on the Action. Find a action called "Create Record"
After selecting the button, You can configure the record by changing the table name to incident, and set the necessary values as mentioned here

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 02:54 AM - edited 01-05-2024 02:55 AM
Hi @Dr Atul G- LNG @Madhav Rao D V ,
I know how to do this using existing actions, I am trying to use scripting in Flow Designer.
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 02:03 AM
Hi @Community Alums ,
So if you wanted to do create an incident through Scripting in flow designer. There are two places in the flow designer to do this.
- Inline Script.
- Custom Actions.
The syntax to create an incident through script is the below code snippet. This syntax can be used in places like Business Rules, Script include etc.
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = "....";
gr.description = "...";
gr.insert();
Inline Scripts: https://docs.servicenow.com/bundle/vancouver-build-workflows/page/administer/flow-designer/concept/inline-scripts.html
The inline scripts space is used to return values to the actions/set values/conditions through scripts instead of using the data pill. You can create incident record in that space and return value of the data pill through script/some other value.
Create custom actions:
https://docs.servicenow.com/bundle/tokyo-application-development/page/administer/flow-designer/concept/actions.html
You can create a simple custom action with one input, script step, one output. In the script step, You can create a incident record.