I want to execute the flow of the flow designer in the UI action

bonsai
Mega Sage

I created a run button on the incident form as shown in the image below.
This was set for the purpose of executing the flow created by Flow Designer.
Is there a way to specify the flow in script and execute it?
I'm thinking of setting the flow to be executed only when the button is pressed.

I'm also thinking of creating a new field, changing the status when the button is pressed, and executing the flow triggered by the status change.
However, I'm wondering if there is any other way than adding more fields or changing the status.

 

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

yes you can make flow trigger from that button

keep that UI action as server side and use this script

var flowInputs = {};
flowInputs['current'] = current;
flowInputs['table_name'] = current.getTableName();

var result = sn_fd.Flow.startAsync('flow name', flowInputs);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

yes you can make flow trigger from that button

keep that UI action as server side and use this script

var flowInputs = {};
flowInputs['current'] = current;
flowInputs['table_name'] = current.getTableName();

var result = sn_fd.Flow.startAsync('flow name', flowInputs);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Maik Skoddow
Tera Patron
Tera Patron

Hi

yes, you can trigger (Sub-Flows) via script. See https://developer.servicenow.com/dev.do#!/learn/courses/rome/app_store_learnv2_flowdesigner_rome_flo...

In your case I recommend using a Sub-Flow as that way you can pass the underlying Incident directly to the Sub-Flow as input parameter.

Kind regards
Maik

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi,

As others have already replied, it is possible to execute a sub-flow. However, if the user pressed the button several times, the sub-flow may be executed several times. Is this OK? Would user be able to press the button after the incident is resolved? Adding all these requirements would make it more complicated.

What is the use case? What is pressing the button suppose to do? There may be a better easier way to satisfy the requirement.

thank you for your answer.
I want to change the status once the button is pressed and hide the UI action button when the status changes.