PrashantLearnIT
Giga Sage

Hello Everyone,

 

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);
    }
})();

 

If my content helped you in anyway, please mark this content as BOOKMARK, SUBSCRIBE & HELPFUL

 

Best Regards,

Prashant Kumar (LearnIT)

 

YouTube Channel LearnIT: https://www.youtube.com/@learnitwithprashant

Blog LearnIT: https://medium.com/@LearnITbyPrashant

Prashant Kumar LinkedIn: https://www.linkedin.com/in/learnitbyprashant/

ServiceNow Community Prashant Kumar - https://www.servicenow.com/community/user/viewprofilepage/user-id/19635

1 Comment