Automate Linking to Service

AJohnston
Contributor
February 28, 2025

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.

image.png

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:

image.png

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?

 

1 answer

1 accepted

3 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2025

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

AJohnston
Contributor
February 28, 2025

The second block did it as is. Thanks, @Bill Sheboy!

image.png

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events