Is there a way to create scripted Flows?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 05:23 PM
Is there a way to create a script in replace of a flow? I know you can execute a flow from script, and can write script in flows, but is there a way to just remove the GUI aspect of creating flows entirely? I made up the code below, but something like this is what I'm envisioning wanting to be able to do.
var fl = new Flow(current);
var group = new GlideRecord('sys_user_group');
group.get('name', 'System Administrators');
var app = new flowApproval(fl);
app.group = group;
app.approveReject = 'anyone';
app.ask();
if (app.state == 'approved'){
var task = new flowCatalogTask(fl);
task.insert();
}
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 05:31 PM
A flow is a business rule and actions are like script includes so just create a business rule. I hope that helps. Now you can create a flow and convert it to code using code snippet option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 05:36 PM
How would you place a business rule "on hold" though? In a flow I can wait x amount of time or wait for an approval, etc. I suppose I could trigger events & run a combination of several business rules on various tables, but I guess I was more so asking if there was some hidden gem that I didn't know about or was potentially in the works for a future release that acted as the processing engine with functions to access the existing flow actions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 05:43 PM
I guess the question is why do you want to do this? if this is related to Service Catalog, then you you can assigned the approver and tasks in the flow against the catalog request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 06:03 PM
Primarily my development preferences I guess? I find myself scripting within flow designer very frequently which just isn't the same as writing code in an actual script field in ServiceNow.
It can be easier to type the variable on the next line than it is to scroll back up or back down in the list of the variables & so on. This feels like a similar question to why someone would want to write code for a website when they could use a GUI designer tool instead.