Create a data gathering action for a dynamic template
Create a data gathering action to collect record field values for a dynamic template input.
始める前に
- Role required: action_designer or admin
- Create credentials and connections for your REST endpoint
注:
Dynamic inputs are not available in the base system. To use dynamic inputs in Workflow Studio, you must Request an Integration Hub plugin.
手順
- Navigate to All > Process Automation > Flow Designer.
- Select Create new > Action.
- In the Action name field, enter a name for your action, choose the proper Application scope, and then select Submit.
- オプション:
From the Action Outline, select Inputs.
You may need to create an input to provide a table name or a dynamic URL path to your REST step.For example, create a String input to store a table name. See Create a data gathering action to get field names for instructions.
-
In the Action Outline under Inputs, select the add a new step icon (
) and select the REST step.
-
From the Connection Details, select a connection alias or define a connection inline.
A connection alias allows you to update connection details without having to edit the action.For example, select an connection alias to your local instance.
-
For the Request Details, select a method to build a request, provide a resource path, select an HTTP method, and provide any query parameters.
Data gathering actions generally use a GET HTTP method to request data from a REST endpoint. For more information on using the REST step in Integration Hub, see REST step and REST in IntegrationHub.
-
From the Connection Details, select a connection alias or define a connection inline.
-
In the Action Outline under the REST step, select the add a new step icon (
) and select the Script step.
- From Input Variables, select Create Variable, and create an input variable to store the REST response body.
- For the input variable Value, select the data pill for the REST step's Response Body output.
-
In Script, enter a script to create a JSON output from the input variable.
Your script needs to do these tasks.
- Parse the input variable as JSON
- You can use the JSON - Global API to transform the input variable from a string to a JSON object.
- Create a new JSON object formatted for a dynamic template
- You must know the data structure of the REST Response to map response values to template values. Your script must create a dynamic template JSON object that has a property named
data. The value of the data property must be an array of template values. Each template value must have alabelproperty, anameproperty, and an emptyvalueproperty. The label property determines how the template value option appears in the action. The name property determines how the template value option is stored and referred to in the system. The value property is empty so that the value can be set dynamically when the action is configured.For example, this JSON object defines an array of template values from the incident table.
{ "data": [ { "name": "parent", "label": "Parent", "value": "" }, { "name": "number", "label": "Number", "value": "" }, { "name": "state", "label": "State", "value": "" }, { "name": "active", "label": "Active", "value": "" }, { "name": "priority", "label": "Priority", "value": "" }, { "name": "caller_id", "label": "Caller id", "value": "" }, { "name": "short_description", "label": "Short description", "value": "" }, { "name": "description", "label": "Description", "value": "" }, { "name": "sys_id", "label": "Sys id", "value": "" }, { "name": "urgency", "label": "Urgency", "value": "" }, { "name": "assigned_to", "label": "Assigned to", "value": "" }, { "name": "severity", "label": "Severity", "value": "" }, { "name": "category", "label": "Category", "value": "" } ] }注:A dynamic template input can only display up to 5000 field template values. A JSON object that returns more than 5000 field template values will be truncated when it is rendered. - Set the outputs object
- Set the outputs object to return your dynamic template JSON object.
-
From Output Variables, select Create Variable.
This output variable stores the template values your script creates.
-
For the output variable type, select JSON.
The script output variable type must be JSON.
-
In the Action Outline, select Outputs
- Select Create Output.
- Set the output label and name output.
-
Set the output type to JSON.
注:The action can have multiple outputs, but there can only be one of type JSON.
- Select Exit Edit Mode.
-
Next to the Value field, select the data pill picker (
) and then select Script step output variable you created to store template values.
-
Click Save and test the
action.
In the execution details, your data gathering action runs successfully if the runtime value for
outputcontains thedataproperty in the proper format. - Click Publish to make the action available to other flows or actions within the same application scope.