Discovery Pattern – JSON Parsing with “Create Table Variable” creates multiple records from array.

Pavan Nagidi
Tera Expert

Hi,

 

 

In a ServiceNow Discovery Pattern, I’m using Run Operation to retrieve a JSON response and then Parse JSON to create a Table Variable, where table columns are populated by selecting values from the JSON response.

When I create the table variable, ServiceNow creates one row per array element, which results in multiple records for the same response. My requirement is to store these values in a single record.

Is there any supported way, using Pattern UI only (no scripting), to merge or transform table-variable rows into one record?


"custom_fields":[{"metadata_id":1790,"label":"cc","value":"IND.01.01.1.1.01.1"},
{"metadata_id":1837,"label":"sac:","value":"GA"}]

 

Thanks in advance

Thanks
Pawan

1 REPLY 1

Fabian Kunzke
Mega Sage

Hey,

 

So this works as designed and intended as these are indeed multi-row results. The only way to get that into one line would be to first define, what the output should look like then. Because you will need to make sure, that it is general enough. Some examples:

1) Always take the first result

2) Take all results, but comma-separate them

3) put all results into a related table

4) put all results into different table fields (e.g. first one into the field 'cc', second one into the field 'sac')

 

If you want to go with the last one and want to map it based on the label, then you won't get around scripting part of your pattern.

 

Regards

Fabian