how to check state of an flow when completed and error caught

Raviteja Kunal1
Tera Expert

Hi All

 

I am trying to trigger an sub flow from UI action. How to get status of the sub flow if it is completed or completed (with caught error). I need this information to process further. 

 

Thank you in advance.

var result = {};
    result['condition'] = 'test';

    var gst = sn_fd.FlowAPI.getRunner()
        .subflow('retrieve_supplier_details')
        .inBackground()
        .withInputs(result)
        .run();

 

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

@Raviteja Kunal1 

your subflow can have output variables defined.

you can get the output of that subflow and proceed further

Also you can use try catch block to handle exception so you know if any error occurred

try{
  var inputs = {};
            inputs['condition'] = 'test';
            var result = sn_fd.FlowAPI.getRunner().subflow('retrieve_supplier_details').inForeground().withInputs(inputs).run();
            var outputs = result.getOutputs();
            gs.info(outputs);
}
catch(ex){
gs.info(ex);
}

Also check this link

How to get outputs from subflow by script, when subflow gets into waiting state? 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar 

 

Even though we have outputs it script is returning value as null

@Raviteja Kunal1 

if subflow is configured to give outputs you should get it, if you are running the subflow in foreground

share complete script

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

This is script calling from UI action 

 

gs.addInfoMessage(' integration inprogress....');

var inputs = {};
inputs['condition'] = 'sys_id=' + current.getUniqueValue();

var result = sn_fd.FlowAPI.getRunner().subflow('retrieve_supplier_details').inForeground().withInputs(inputs).run();

var outputs = result.getOutputs();

action.setRedirectURL(current);