Flow API - Service Catalog Input

Jocel_s
Tera Expert

I have a flow that I want to have an interaction programmatically. Its trigger is a service catalog. It doesn't have inputs as the service catalog is the input itself.

 

I'm using this API ref: https://docs.servicenow.com/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/Scri...

 

When a flow has no inputs but gets triggered by a service catalog. How do I pass the service catalog object as a parameter?

The documentation only includes inputs. Nothing for service catalog trigger.

 

I tried to pass a glidrecord object as an input but I get a datatype mismatch. 

1 ACCEPTED SOLUTION

I have figured out the solution:

 

var grIncident = new GlideRecord('sc_req_item');
grIncident.get('6a173ae41b9c8e901c8f6570604bcb00');

var inputs = {};
inputs['request_item'] = grIncident;

var result = sn_fd.FlowAPI.getRunner()
      .flow('x_gup_ansible_inte.new_server_build')
      .withInputs(inputs)
      .inForeground()
      .run();

gs.info(result.debug());

 

View solution in original post

6 REPLIES 6

Sorry, the requirement is not clear because if we want to generate requested item, then cart api can be used which will automatically trigger the flow associated with the catalog item.

 

If your requirement is to design a single flow which can be used for multiple catalog items, then you may  explore dynamic flows

 

https://docs.servicenow.com/bundle/xanadu-build-workflows/page/administer/flow-designer/concept/flow...

 

Below is OOB script which tags flow to the RITM automatically

startFlowDesignerFlow(current);

function startFlowDesignerFlow(current) {
	var flow = current.cat_item.flow_designer_flow;
	var flowName = flow.sys_scope.scope + "." + flow.internal_name;

	sn_flow_trigger.FlowTriggerAPI.fireCatalogTrigger(flowName, current); 
}

 

I have figured out the solution:

 

var grIncident = new GlideRecord('sc_req_item');
grIncident.get('6a173ae41b9c8e901c8f6570604bcb00');

var inputs = {};
inputs['request_item'] = grIncident;

var result = sn_fd.FlowAPI.getRunner()
      .flow('x_gup_ansible_inte.new_server_build')
      .withInputs(inputs)
      .inForeground()
      .run();

gs.info(result.debug());