Is there a way to create scripted Flows?

PB20201617
Kilo Contributor

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();
}
6 REPLIES 6

Sukraj Raikhraj
Kilo Sage

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. 

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.

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. 

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.