How to trigger Sub flow (Flow designer) using business rules

Madhan27
Mega Guru

I am trying to create a business to trigger Sub flow for an closed alert,  I copied the flow designer code snippet and pasted in the business rules but I am not getting what are the values to be given for the below following.

 

Madhan27_0-1702822414107.png

 

Thanks in advance. 

1 ACCEPTED SOLUTION

Madhan27
Mega Guru

We need to set the conditions when to run and in actions with the below following script its calling the flow designer on closed alerts.

 

 

(function executeRule(current, previous /*null when async*/ ) {

    (function() {


        try {

            var inputs = {};
            inputs['ah_alertrulename'] = 'ICO Fault Management Flow';
            inputs['ah_alertruleid'] = 'dee9da63873971d035a90e96cebb3530';
            inputs['ah_alertgr'] = current;
            var result = sn_fd.FlowAPI.getRunner().subflow('global.ico_fault_management_flow').inForeground().withInputs(inputs).run();
            var outputs = result.getOutputs();

        } catch (ex) {
            var message = ex.getMessage();
            gs.error(message);
        }

    })();

View solution in original post

5 REPLIES 5

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
You can if this subflow is used in somewhere in some other flow and check the type of input needed for this.

 

 


Thanks and Regards,

Saurabh Gupta

shloke04
Kilo Patron

Hi @Madhan27 

To achieve this you are on the right track, you need to follow below steps to pass the inputs:

 

For example see below on how you can achieve this based on the screenshot which you have shared:

 

inputs['This will be the name of the input you have defined within your Subflow right at the top of subflow'] = current,getValue('Field Name from Alert Table which you want to pass as an input'); 

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Madhan27
Mega Guru

HI @shloke04 ,

Thank you for your response, I have gave the inputs even though the alert executions were not updating when the alert is closed. 

 

Madhan27_0-1702911479772.png

 

Madhan27_1-1702911540870.png

 

AJ-TechTrek
Giga Sage
Giga Sage

Hi,

have a look at the new ScriptableFlowRunner API. This is what you should be using currently to start flow/subflow/action from a server script.

Basically you instantiate the Runner object with any parameters you need and then you can access the Result object to see response attributes. You will be most interested in the Outputs.

 

https://developer.servicenow.com/dev.do#!/reference/api/utah/server/sn_fd-namespace/ScriptableFlowRu...

 

Thanks

Ajay