UI Action that triggers Flow with user input as well as the current RITM sys_id

Elliott2
Tera Expert

Its been a while since I've messed with UI pages and UI actions, but my goal is clear

 

I have a UI action that shows a UI page

This UI page is meant to take user input, then trigger a Flow Designer flow

 

Flow inputs are:

The current Requested Item sys_id

Filername [string]

Path [string]

 

All other inputs will be read by the Flow from the RITM variables

 

The OK button should be disabled once clicked to prevent multiple submissions.

There should also be a confirm dialog to make sure the user validates their input before continuing.

The form should redirect back to the current RITM page once the Flow has been successfully triggered.

 

UI Action is client side and currently has this script

function showPage(){
	var gm = new GlideModal('tool_runner');
	gm.setTitle('Tool Parameters');
	gm.setPreference('sysparm_req_item_id', g_form.getUniqueValue());
	gm.render();
}

 

The UI Page HTML contains this:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
	<g:ui_form>
		<label for="filername">Filer Name:</label><br />
		<input type="text" id="filername" name="filername" placeholder="sharename"/><br />
		<label for="path">Path:</label><br />
		<input type="text" id="path" name="path" placeholder="path"/><br /><br />
		<g:dialog_buttons_ok_cancel ok="return executeTool()"/>
	</g:ui_form>
	<g2:evaluate var="jvar_req_item_id" expression="RP.getWindowProperties().sysparm_req_item_id" />
</j:jelly>

 

The Client Script currently contains the following:

 

function executeTool() {
	var ok = document.getElementById("ok_button");
	ok.disabled = true;
	
}

 

 

And the code I will use to trigger the Flow (which I expect goes in the processing script block) is as follows:

var flowInputs = {};
flowInputs['requested_item'] = current.request_item;
flowInputs['filername'] = request.getParameter('filername');
flowInputs['path'] = request.getParameter('path');
var result = sn_fd.Flow.startAsync('my flow', flowInputs);

 

However, I don't know how to execute this in the processing script, getting the values from the g2:evaluate statements, and actually trigger the flow.

1 REPLY 1

AnveshKumar M
Tera Sage
Tera Sage

Hi @Elliott2 

 

To run a flow from script, check the following article.

 

https://developer.servicenow.com/dev.do#!/learn/learning-plans/utah/servicenow_application_developer...

 

 

Thanks,
Anvesh