logo

NJP

127. Flow API

Import · Jun 11, 2024 · article

In ServiceNow, the Flow API provides a powerful capability to execute actions from server-side scripts asynchronously, without creating execution details or other related records. This approach improves performance by eliminating record-keeping overhead, making it ideal for high-volume processing tasks.

Here’s an example script demonstrating how to use the Flow API to run an action asynchronously:

Parameters

Name

Type

Description

name

String

Scope and internal name of the action to execute. For example, global.action_name. Locate the Internal name field in the list of Flow Designer actions.

inputs

Map

Name-value pairs that define action inputs. You can find the available action inputs and required data types under Inputs in the action outline. Use the input name, not the input label. For example, {‘table’:’incident’,’sys_id’:’a39d8e3cf0212300964feeefe80ff0e

Returns

Type

Description

void

Method does not return a value

Example Script below :

(function() {

try {

// Retrieve the desired record using GlideRecord

var grIncident = new GlideRecord(‘incident’);

grIncident.get(‘57af7aec73d423002728660c4cf6a71c’);

// Define input parameters for the action

var inputs = {};

inputs[‘variable’] = grIncident;

// Specify the scope and internal name of the action to execute

var actionName = ‘global.update_record_test’;

// Start the action asynchronously using the Flow API

sn_fd.FlowAPI.startActionQuick(actionName, inputs);

} catch (ex) {

// Handle any exceptions gracefully

var message = ex.getMessage();

gs.error(message);

}

})();

View original source

https://medium.com/@LearnITbyPrashant/127-flow-api-fcca07f1d49a?source=rss-d005fc598f0a------2