The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Meghnath Kale1
Giga Expert

Calling Flow designer from Workflow When you are using both workflow and flow designer for service catalog

1. Before implementing this hope you have installed Flow Designer support for the Service Catalog(com.glideapp.servicecatalog.flow_designer) plugin and created catalog item.

2. Create Flow designer.

Flow Designer --> Designer -->  New

find_real_file.png

3. Add Trigger condition as Service Catalog.

4. Add First Action as Get Catalog variable.

    In which here need to provide Catalog Item name.

    Please refer the below snap. 

find_real_file.png

5. Create Workflow 

    Workflow --> Workflow Editor --> New Workflow

     Add one core activity "Run Script".

6. Add below script in the run script : 

       

              var flowInputs = {};

             flowInputs['request_item'] = current;
             flowInputs['table_name'] = current.getTableName();

         var result = sn_fd.Flow.startAsync('global.alternate_approval', flowInputs);//alternate_approval is a catalog item name

 

7. For Knowing the execution (sys_flow_context) of flow based on RITM.

 Add flow context field (OOB Present no need to create) from Form Layout/Form Design on the RITM(sc_req_item) form.

    find_real_file.png

  

      Add below code in the same run script, it will update the name of flow execution in the flow context field. 

 

       //The Sys ID of a flow execution (contextId)
          var contextId = result.contextId;

          current.flow_context = contextId;
          current.update();

find_real_file.png

8. Add the workflow in the catalog item.

 Catalog Item --> Process Engine --> Workflow.

find_real_file.png

 

This blog is only for service catalog related execution not for table execution and for table related execution i will post another blog.

                                                     

                                                                                   Thank You !!!

 

Regards,

Meghnath

Comments
Srivani Khammam
Tera Contributor

Hi,

I'm looking for calling a flow from the existing Service Catalog workflow. Just to clear some things on this post, where are we specifying the flow name in the workflow run script? Also, do we have to pass the catalog item name or workflow name? There it is specified catalog item name so was the item name defined as "alternate_approval"?

 

 

P-Rudenko-SN
ServiceNow Employee
ServiceNow Employee

Hi @Meghnath Kale 

Thanks for your post - really helpful one. I have a further question in terms of it: how can I let the Workflow continue when the Flow is ended? I need to place the Flow in the mid of the Workflow.

Thanks.

shanedavis
Tera Contributor

@Pavlo Rudenko  @Meghnath Kale   Is there a solution to let the Workflow continue when the Flow is ended?  My Run Script to trigger the Flow is in the middle of my workflow. Thank you for any help that you can give!

shanedavis
Tera Contributor

Disregard.  You comment out the "Start Asynchronously" line and uncomment the line for "Execute Synchronously".  

(function() {

    try {
        var inputs = {};
        inputs['table_name'] = 'Table Name';
        inputs['request_item'] = current; // GlideRecord of table: sc_req_item 

        // Start Asynchronously: Uncomment to run in background.
        // sn_fd.FlowAPI.getRunner().flow('global.shane_test').inBackground().withInputs(inputs).run();

        // Execute Synchronously: Run in foreground.
        sn_fd.FlowAPI.getRunner().flow('global.shane_test').inForeground().withInputs(inputs).run();

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

})();
Savitha Raghu
Tera Contributor

Hi Meghnath,

 

I have followed all the above steps you have mentioned, but for some reason the Run script on my workflow is showing an error "The flow named: <Flow Designer Name> does not exist within application scope: global".

 

I tried with both Flow designer name and Catalog name, both results with same error.

Could you please help me to sort this out.

 

Thanks in advance,

Savitha

Brian Lancaster
Giga Sage
Giga Sage

I'm not sure I see it. How can you tell if the flow was successful so you can continue the workflow?

Sangita Swamina
Tera Contributor

To call a flow from a wokflow, Use a Run Script with below code. The flow must be in Global scope to call from a workflow although I am not sure where to specify scope app if needed.

 

(function execute() {

sn_fd.FlowAPI.executeFlow('Flow_name');

})();

 

 

Version history
Last update:
‎12-20-2019 01:26 AM
Updated by: