Result Path | Result Selector | Circuit | Online Help | Customizing State Output for Seamless Processing | Flexible Data Manipulation for Dynamic Applications

Result Selector and Result Path

Result Path and Result Selector are employed to extract dynamic data from the state's result when the execution is successful.

Result Selector  

Result Selector lets you retrieve and process the runtime data, enabling flexible and dynamic data manipulation within your application. With this, you can precisely control the relevant and essential parts of the state's result, excluding unnecessary data or modifying existing values as needed.

To implement the desired modifications, you define key-value pairs where each key represents a specific result modification. The corresponding values associated with these keys can be either static or dynamically derived from the state's result. By using the Result Selector, you can tailor the data to be sent to the Result Path based on your specific needs.

Consider the following JSON data received as an output of a task or function execution in a State: 

{
"status": "success",
"message": "Employee onboarded successfully.",
"emp_id": "543",
"name": "Martin",
"department": "Product Management",
"joining_date": "2023-07-23",
"designation": "PM Associate",
"manager": "Jane Smith",
"location": "New York",
"salary": 75000,
"benefits": [
"Health Insurance",
"401(k) Plan",
"Paid Time Off"
],
"documents": {
"offer_letter": "offer_letter_EMP12345.pdf",
"employment_contract": "empcontract_EMP12345.pdf",
"tax_forms": "tax_forms_EMP543.pdf"
}
}


Suppose the employee_department and offer_letter alone in this result is expected in the next state, here's how it can be achieved using the Result Selector in Code view:

{
"get_employee_details": {
"type": "circuit",
"next": "End",
"start": true,
"circuit_id": "<Circuit_Name>",
"result_path": "$.Output",
"result_selector": {
"employee_department": "$.department",
"letter_of_intent": "$.documents.offer_letter"
}
}
}


The given definition of the Result Selector produces the following output:

"output": {
  "employee_department": "Product Management",
"letter_of_intent": "offer_letter_EMP543.pdf"
}


Only the necessary information is extracted from the result and passed as output.
For configuring JSON Path expressions in the Result Selector, refer to the Context Object.

Result Path

Result Path enables you to adjust the output of a state. Within the Result Path, you can specify the state's input, the state's result, or a combination of both as the state's output. Essentially, you have the option to append the state's result to the JSON input given to the state and make alterations. You can then pass this modified JSON as the state's output to the next state for processing. It's important to note that if the Result Selector is configured, Result Path becomes mandatory.

Result Path is available for all the states except Branch, Wait, Success, and Failure.

If the Result Path is not specified, the state will discard the result and retain the original input.

For example, let the following JSON be the state input for your execution: 

{
"org_name": "Global Solutions",
"employee_details": {
"name": "Martin",
"emp_id": "543",
"role": "PM Associate"
}
}

Let the state result received be the following:

"location": "New York"

To keep the state input intact and to append the state result to it, set result_path to $.location:

{
"get_employee_details": {
"type": "pass",
"next": "End",
"start": true,
"result_path": "$.employee_details.location",
"result": "New York"
}
}


This includes the state result with the actual input:

{
"org_name": "Global Solutions",
"employee_details": {
"name": "Martin",
"emp_id": "543",
"role": "PM Associate",
"location": "New York"
}
}

In the event of a failed execution, the data can be refined utilizing Error Path and Error Selector.




    • Related Articles

    • Error Selector and Error Path

      Error Selector and Error Path are used to manage errors in a system. While Result Selector and Result Path control the output of a state upon successful execution, Error Selector and Error Path come into play when the are exceptional circumstances, ...
    • Output Path

      Output Path enables you to select a portion of the state's output and transfer it to the next state for processing, eliminating any unecessary objects from the JSON output. If the Output Path isn't specified, the entire JSON node (determined by the ...
    • Input Path

      Input Path enables you to filter and control the actual input passed to the state. By defining an Input Path (either in Builder View or Code View), using JSONPath notation, you can select a portion of the JSON input and use it for processing within ...
    • JSON Path

      Path serves to locate specific parts or components within a JSON object. These paths start with the '$' symbol and follow JSONPath syntax. It is used to access particular elements or values within JSON objects passed in the Input Path, Output Path, ...
    • Advanced Fields

      Lookups Lookups are fields used to obtain a subset of options from available values in fields, tables, webhook API responses, or database query responses. Existing data available in the organization can be reused using lookups. Lookups usually return ...

    You are currently viewing the help articles of Qntrl 3.0. If you are still using our older version and require guidance with it, Click here.