The Pass state in the circuit merely forwards the data to the next defined state. It allows you to pass the input data as-is or include supplementary information if needed during the process. To put it differently, with this state, you can insert new data or make changes (or manipulations) to the input JSON data by configuring Input path, Output path, or Result path fields. To know more about these paths, refer Input & Output processing section.
Besides the common fields, Pass state also has an additional Result field which is not available in any other states. This field is used to insert a new object into the input JSON data and pass the modified JSON data as the input to the next state. The path of the new object added to the input is to be defined in the Result Path. If the Result Path and Result are not specified in the circuit, the state simply passes the input data as such to the next state.
Use case Example: Let's consider the use case of automating IT tasks involved in the employee onboarding process. In this scenario, the HR department supplies the new employee details as an input JSON to the circuit, which includes attributes like name, date of birth, and role. Now, the HR department wants to augment the input JSON with additional data, like the employee's work location, and then pass this modified input to the next state in the process.
To achieve this, the path for the new attribute to be added in the input JSON has to be specified in the Result Path field, which is represented as '$.key'(Ex: $.location) and the corresponding value for the new attribute has to be specified in the Result field. As a result, the modified JSON input to the next state will include the objects with attributes for name, date of birth, role, and location.
We will now explore the steps to configure the mentioned process in the Pass state, both in Builder View and Code View.
Builder view
In Builder View, drag and drop the Pass state from the left pane into your circuit or click the required pass state in your circuit. Select the Input/Output tab located on the right side of the builder View page, and establish the paths. For further details, refer to the Input/Output Processing section. For inserting a new parameter to the input passed, enter the key (in format '$.fieldname') in ResultPath and the value within Result.
Code view
In Code View, you can directly add the parameters resultPath and result within the state.
Let the JSON input to the state is: {
"org_name": "Global Solutions",
"EmployeeDetails": {
"name": "Henry",
"date of birth": "15-03-1990",
"role": "Business Analyst"
}
}
In Pass state, you can add the new parameter location in the result Path as below:
"Get Employee Details": {
"start": true,
"type": "pass",
"next": "End",
"input_path": "$.EmployeeDetails",
"output_path": "$.EmployeeDetails",
"result_path": "$.location",
"result": "CA"
}
Then the JSON output will be:
{
"org_name": "Global Solutions",
"EmployeeDetails": {
"name": "Henry",
"date of birth": "15-03-1990",
"role": "Business Analyst",
"location": "CA"
}
}