ScriptableFlowRunnerResult - Scoped
Captures the result of using ScriptableFlowRunner to execute a flow, subflow, or action. Includes data such as the context ID, domain, and any outputs from the flow execution.
Use these methods in your server-side scripts with the sn_fd namespace
identifier.
API call Order
Build and execute flows, subflows, and actions using these APIs in the following order:
- 1. FlowAPI: Creates a builder object
- Use getRunner() to instantiate the ScriptableFlowRunner builder object.
- 2. ScriptableFlowRunner: Specify Workflow Studio content to run
- Use these methods in the following order to create the builder pattern:
- Use one of the methods action(), datastream(), flow(), or subflow() to specify what type of Workflow Studio object to build.
- Use one or more methods such as addInput(), inDomain(), or quick() to specify execution parameters.
- Use the run() method to run the action, flow, or subflow with the provided parameters and return a ScriptableFlowRunnerResult object.
- 3. ScriptableFlowRunnerResult: Retrieve Workflow Studio execution details
- Use one or more methods such as getContextId(), getOutputs(), and getDomainId() to view execution details.
Example
This example shows how to create a ScriptableFlowRunner builder object and uses it to execute an approval action on a specific record. A ScriptableFlowRunnerResult object captures the execution arguments and action outputs.
(function() {
try {
var inputs = {};
inputs['sys_id'] = '57af7aec73d423002728660c4cf6a71c'; // Pass the record's sys_id in as input.
var result = sn_fd.FlowAPI.getRunner() // Create a ScriptableFlowRunner builder object.
.action('global.markapproved') // Run the global scope action named markapproved.
.inForeground()
.inDomain('TOP/ACME') // Run the action from the TOP/ACME domain.
.withInputs(inputs)
.run(); // Run the action and return a FlowRunnerResult object.
var contextId = result.getContextId(); // Retrieve the context ID from the result
var dateRun = result.getDate();
var domainUsed = result.getDomainId(); // Retrieve the Domain ID from the result.
var flowName = result.getFlowObjectName();
var flowObjectType = result.getFlowObjectType();
var outputs = result.getOutputs(); // Retrieve any outputs from the action execution.
var newApprovalStatus = outputs['approval']; // Echo back the approval status for verification.
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
ScriptableFlowRunnerResult - debug()
Returns information about the executed flow, subflow, or action, including the context ID, domain ID, and execution outputs.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| String | Execution details about the Workflow Studio action, flow, or
subflow run.
|
This example shows how to retrieve information about the executed flow, subflow, or action from the ScriptableFlowRunnerResult object.
(function() {
try {
var result = sn_fd.FlowAPI.getRunner()
.flow('global.test_flow')
.inForeground()
.timeout(12000)
.run();
gs.info(result.debug());
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
*** Script: FlowRunnerResult
Flow Object Name: global.test_flow
Flow Object Type: flow
Domain: null
Result Time: 2020-06-08 18:28:41
ContextId: null
Output count: 0
ScriptableFlowRunnerResult - getContextId()
Returns the context ID of the flow, subflow, or action.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| String | The sys_id of the Workflow Studio execution details record for the action, flow, or subflow. |
This example shows how to retrieve a context ID from a ScriptableFlowRunnerResult object.
var contextId = result.getContextId();
4ecead85c4da1110598d0c7d6bf73554ScriptableFlowRunnerResult - getDate()
Returns the date and time when a Workflow Studio action, flow, or subflow ran as a GlideDateTime object.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| GlideDateTime | The execution date and time for the flow, subflow, or action. |
This example shows how to retrieve the date and time of a flow execution from a ScriptableFlowRunnerResult object.
(function() {
try {
var result = sn_fd.FlowAPI.getRunner()
.flow('global.test_flow')
.inForeground()
.timeout(12000)
.run();
gs.info(result.getDate());
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
2020-05-22 18:45:42ScriptableFlowRunnerResult - getDataStream()
Returns the stream of data from a data stream action.
If the datastream() method was used in the ScriptableFlowRunner builder class, this returns the stream of data as a ScriptableDataStream object. Use the ScriptableDataStream class to iterate over items in the stream. See ScriptableDataStream.
For more information about data stream actions, see Data Stream actions and pagination.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| ScriptableDataStream | A ScriptableDataStream object you can use to iterate through items in a data stream. Use the methods in the ScriptableDataStream class to interact with this object. See ScriptableDataStream. |
This example shows how to retrieve a data stream from a ScriptableFlowRunnerResult object.
var datastream = result.getDataStream();
ScriptableFlowRunnerResult - getDomainId()
Returns the sys_id of the domain that the Workflow Studio action, flow, or subflow ran in.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| String | The sys_id of the domain that the Workflow Studio action, flow, or subflow ran in. |
This example shows how to retrieve a domain ID from a ScriptableFlowRunnerResult object.
(function() {
try {
var result = sn_fd.FlowAPI.getRunner()
.flow('global.test_flow')
.inForeground()
.inDomain('TOP/ACME')
.timeout(12000)
.run();
gs.info(result.getDomainId());
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
4ecead85a4da1110598d0c7d6bf75554ScriptableFlowRunnerResult - getFlowObjectType()
Returns the type of Workflow Studio object run.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| FlowObjectType | The type of Workflow Studio object run, which is either action, flow, or subflow. |
This example shows how to retrieve the flow object type from the ScriptableFlowRunnerResult API.
(function() {
try {
var result = sn_fd.FlowAPI.getRunner()
.flow('global.test_flow')
.inForeground()
.timeout(12000)
.run();
gs.info(result.getFlowObjectType());
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
flowScriptableFlowRunnerResult - getFlowObjectName()
Returns the scope and internal name of the Workflow Studio action, flow, or subflow run.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| String | The scope and internal name of the Workflow Studio action, flow,
or subflow run. For example, global.emailflow. |
This example shows how to retrieve the name of the flow, subflow, or action name from a ScriptableFlowRunnerResult object.
(function() {
try {
var result = sn_fd.FlowAPI.getRunner()
.flow('global.test_flow')
.inForeground()
.timeout(12000)
.run();
gs.info(result.getFlowObjectName());
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
global.test_flowScriptableFlowRunnerResult - getOutputs()
Returns the outputs of a completed Workflow Studio action, flow, or subflow.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| Object | Object containing the output of a completed Workflow Studio action, flow, or subflow. |
This example shows how to retrieve the outputs from a Workflow Studio action, flow, or subflow run with the ScriptableFlowRunner API.
(function() {
try {
var result = sn_fd.FlowAPI.getRunner()
.action('global.test_action')
.inForeground()
.timeout(12000)
.run();
gs.info(result.getOutputs());
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
Flow Designer: Warning. This is an important log message.