Call a Flow action from Script Include

maryc
Tera Contributor

Hi,

 

I have an action that returns a value . I want to call this action from a Script include. Is it possible to do?

 

Thanks in advance

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hello,

You can call the action from script include like this.

Ref: https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/sn_fd-namespace/ScriptableFlo...

(function() {
  try {

    var grIncident = new GlideRecord('incident');
    grIncident.get('57af7aec73d423002728660c4cf6a71c');

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

    var outputs = sn_fd.FlowAPI.executeActionQuick('global.update_record_test', inputs);

    // Get Outputs:
    // Note: outputs can only be retrieved when executing synchronously.
    var output1 = outputs['output1']; 

  } catch (ex) { 
    var message = ex.getMessage();
    gs.error(message);
    }
	
})();

Mark the comment as a correct answer and also helpful if this has answered the question.

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@maryc 

there is this function for calling the flow action -> executeAction

Refer below links

FlowAPI Methods

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

asifnoor
Kilo Patron

Hello,

You can call the action from script include like this.

Ref: https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/sn_fd-namespace/ScriptableFlo...

(function() {
  try {

    var grIncident = new GlideRecord('incident');
    grIncident.get('57af7aec73d423002728660c4cf6a71c');

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

    var outputs = sn_fd.FlowAPI.executeActionQuick('global.update_record_test', inputs);

    // Get Outputs:
    // Note: outputs can only be retrieved when executing synchronously.
    var output1 = outputs['output1']; 

  } catch (ex) { 
    var message = ex.getMessage();
    gs.error(message);
    }
	
})();

Mark the comment as a correct answer and also helpful if this has answered the question.

@asifnoor hi

 

Do you know if it is possible to pass different connection and target host parameters to the `executeActionQuick` function call?

 

If I run this as a Test in Flow I see that metadata referred to, but not sure how I might pass that in.

 

DavidHubbard_0-1695919156686.png

My reason for asking is we are developing a scoped Store Application and considering that client organisations may want to limit the credentials that a ServiceNow user can use - the API Token in Jira seems to be "user specific" and use that users permissions.  So two different projects in Jira may require two different API Tokens to access - and hence a credential (and possibly different target host) need to be selected and used on Spoke call.

 

Edit:  Having posted this I found the API references - I notice two things:

1) That "executeActionQuick" is deprecated and "This API is replaced by ScriptableFlowRunner, which deprecates the existing methods used to build objects and execute Flow Designer flows and actions"

2) "ScriptableFlowRunner" has a method "withConnectionAliasOverride" - which may fit my requirement.

 

Thanks in advance

David