Run Flow on Req Item via Script

Tom B
Tera Contributor

I have a requirement in which I need to create an sc_task from an inbound REST call attached to an existing RITM. I then need to watch that task and close the RITM when the task is closed. The problem is that I'm running into a wall when it comes to triggering the Flow. Since it's on a Service Catalog table I can only use the Service Catalog trigger (which is apparently an Orlando change) and I can't seem to find the right set of inputs to fire the Flow from the Scripted REST action.

Has anyone found the right set of inputs or a way to trigger the Flow from script on a Service Catalog item?

Thanks

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hi Tom,

If the REST call is creating a task and you effectively need to attach a flow onto the record in order to close it once a criteria is met, you can create a subflow and use the cope snipped it provides to then complete what you need.

First question - can't you simply setup a business rule that auto-closes the RITM when no open tasks remains (believe this is even OOB behaviour) or are you wanting to force close the RITM even if other tasks are currently open/active?

Regarding your needs:

Create a subflow with a reference input to the catalog task [sc_task] table.

find_real_file.png

Add a wait condition for the catalog task provided as an input

find_real_file.png

Once the wait condition is met, use an update record action to close the RITM.

find_real_file.png

Flow can then provide the code snippet to call the flow (note the below is the new Flow API for paris, your instance will provide the API function for Orlando and below).

(function() {
	
	try {
		var inputs = {};
		inputs['catalog_task'] = ; // GlideRecord of table: sc_task - pop the record just created here.

		var result = sn_fd.FlowAPI.getRunner().subflow('global.close_ritm').inBackground().withInputs(inputs).run();
		var outputs = result.getOutputs();	
	
	} catch (ex) {
		var message = ex.getMessage();
		gs.error(message);
	}
	
})();

View solution in original post

4 REPLIES 4

Kieran Anson
Kilo Patron

Hi Tom,

If the REST call is creating a task and you effectively need to attach a flow onto the record in order to close it once a criteria is met, you can create a subflow and use the cope snipped it provides to then complete what you need.

First question - can't you simply setup a business rule that auto-closes the RITM when no open tasks remains (believe this is even OOB behaviour) or are you wanting to force close the RITM even if other tasks are currently open/active?

Regarding your needs:

Create a subflow with a reference input to the catalog task [sc_task] table.

find_real_file.png

Add a wait condition for the catalog task provided as an input

find_real_file.png

Once the wait condition is met, use an update record action to close the RITM.

find_real_file.png

Flow can then provide the code snippet to call the flow (note the below is the new Flow API for paris, your instance will provide the API function for Orlando and below).

(function() {
	
	try {
		var inputs = {};
		inputs['catalog_task'] = ; // GlideRecord of table: sc_task - pop the record just created here.

		var result = sn_fd.FlowAPI.getRunner().subflow('global.close_ritm').inBackground().withInputs(inputs).run();
		var outputs = result.getOutputs();	
	
	} catch (ex) {
		var message = ex.getMessage();
		gs.error(message);
	}
	
})();

Hi Kieran,

Thanks for the very detailed reply! I ended up figuring out how to attach a subflow before the question made it through moderation.This answer is definitely helpful for additional work I have on other projects though, so thank you!

To answer the question regarding creating a business rule: There are points where the ticket is still being worked where all tasks may be closed, but the RITM still has work left or a delay before more tasks are created.

Glad to hear you solved the issue 🙂 

Hi Tom, can you mark an answer correct to close this question.