The ultimate goal is to add Teams automatically to Responders when Customer Locations (as Assets so options can be limited when viewed by the requestor) are selected. What I've done is duplicate Customer Locations as Services and set the various teams as Responders on the services.
The problem is I can't figure out the JSON to select the matching Service.
Scenario: Customer A has selected both Location A and Location B from the Location asset field.
The automation takes the Name of each location, looks up the matching Services.
This works exactly as intended. It's when trying to update the Affected services field that everything falls apart.
If I log
{{lookupObjects.Service ID}}
I'll get
ari:cloud:graph::service/<GUID>/<GUID>, ari:cloud:graph::service/<GUID>/<GUID>
which is exactly what I want. Per the API, the field looks like this:
But if I try
{{lookupObjects.Service ID.asJsonObjectArray("id")}}
I'll get this instead
[{ "id": "6640" },{ "id": "6623" }]
My understanding of the asJsonObjectArray("id") is that it's supposed to cast the value to an key/value pair, where key is "id" and the value is whatever the value is. Instead, the value is.... unknown. I don't know where those IDs are coming from, because they aren't in the GUIDs, and they aren't the objectIds in Assets.
So... what am I doing wrong?
Hi @AJohnston
I hypothesize the id values you are seeing are the internal ones representing the values. Please try using that JSON function to get the value attribute, and then replace "value" with "id" as the attribute for JSON update:
{{lookupObjects.Service ID.asJsonObjectArray("value").replace("value", "id")}}
If that does not work, you may try to iterate over the values directly to build the JSON, although that may require additional encoding:
[
{{#lookupObjects.Service ID}}
{ "id": "{{.}}" } {{^last}}, {{/}}
{{/}}
]
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.