Decision Table output is JSON which should be parsed to string

sravyab
Tera Contributor

I have a requirement where i should use decision table for auto assignment of group.. i created decision table and used that in flow designer with action DT -First result evaluation ..Outpput of that action is stored in JSON.

That JSON contain sys id means decision table result elements...inside the result elements i will have assignment group..Now i need script action to convert that JSON to string and use in update record action to update assignment group..

1 REPLY 1

Pavan Srivastav
ServiceNow Employee

Hello Sravya

 

To convert the JSON output from a decision table in Flow Designer to a string and use it in an Update Record action for updating the assignment group, follow these steps:

  1. Extract the Assignment Group sys_id from the JSON: The decision table output JSON contains result elements, where each answer element (such as assignment group) is represented with its name and value (sys_id) ​1️⃣​.
  2. Stringify the JSON or Extract the Value: Use a script step in Flow Designer to parse the JSON and extract the assignment group sys_id as a string. For example: var result = JSON.parse(decisionTableOutput); var assignmentGroupSysId = result.result.answerElementValues.find(function(element) { return element.answerElementName === 'assignment_group'; }).value; This extracts the sys_id as a string for use in the next step ​1️⃣​.
  3. Use in Update Record Action: Pass the extracted assignment group sys_id string to the Update Record action to update the assignment group field.
  4. Best Practices: If you need to convert the entire JSON object to a string, use JSON.stringify(result) as described in custom payload generation for similar integrations ​2️⃣​. When using the JSON Parser Action Step, ensure your JSON is properly formatted and does not exceed size or structure limitations ​3️⃣​.

This approach ensures you can reliably extract and use the assignment group sys_id from the decision table output in your flow