…thoughts on ServiceNow and digital transformation


Launch a ServiceNow Flow from an ATF Test

1. Create a Step Configuration. I created this in the Global scope

Description Generation Script

var description = "Launches Flow: " + step.inputs.u_flow.getDisplayValue();

return description;

Step Execution Script

(function executeStep(inputs, outputs, stepResult, timeout) {
    var appScope = inputs.u_flow.sys_scope.scope.getDisplayValue();
    var flowName = inputs.u_flow.internal_name.getDisplayValue();

    var fullFlowName = appScope + "." + flowName;

    var result = sn_fd.FlowAPI.getRunner().flow(fullFlowName).inForeground().run();

}(inputs, outputs, stepResult, timeout));

2. Add an Input Variable to the Step Configuration

Reference table is sys_hub_flow

3. Create an ATF Test. Use the Launch Flow step created in step 1. Select the Flow you want to launch in the list

4. Run the test. If you get ATF Test fails with error “Security restricted: Execute operation on API ‘StepResult.setSuccess’ from scope …. was denied”, add a cross scope record as outlined in this knowledge article: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0790323