Hi,
we need to send emails to various customers in case of incidents.
The customers are organized in assets which have an email attribute.
As there are more than 100 customers we can't use "lookup objects" action.
So we need to make a REST call to the assets API and retrieve the data via AQL.
The result is a very big JSON with many json objects and many attributes. I do not find a way to retrieve only the Email addresses via smart values notation.
Example JSON
{
"startAt": 0,
"maxResults": 2,
"total": xx,
"values": [
{
"workspaceId": "...",
"globalId": "...",
"id": "123",
"label": "Name 1",
"objectKey": "ORG-111,
"avatar": {... },
"objectType": { ... },
"created": "2024-03-25T13:44:09.953Z",
"updated": "2024-03-25T13:44:09.953Z",
"hasAvatar": false,
"timestamp": 123,
"attributes": [
{
"workspaceId": "...",
"globalId": "...",
"id": "111",
"objectTypeAttributeId": "212",
"objectAttributeValues": [
{
"value": "ORG-123",
"searchValue": "ORG-123",
"referencedType": false,
"displayValue": "ORG-123"
} ],
"objectId": "222" },
...
{
"workspaceId": "....",
"globalId": "...",
"id": "413764",
"objectTypeAttributeId": "277",
"objectAttributeValues": [
{
"value": "support@xy.de",
"searchValue": "support@xy.de",
"referencedType": false,
"displayValue": "support@xy.de"
}
],
"objectId": "30380"
}, ...
I need to get alle values from attribute ID 277
I tried something like this but no notation gets me to an end:
{{#webResponse.body.value.attributes}}
{{#if(objectTypeAttributeId.equals("277"))}}
{{objectAttributeValues.value}},
{{/}}
{{/}}
Also every other plan to retrieve the email addresses is valid.
Thanks for your help.
Christof
I recall sometimes web responses in rules do not fully resolve as JSON that can be accessed with dot-notation. Let's validate that using the Log action...
Please use Log actions to write each of these to the log after the response is returned, validating if they contain what you expect:
The first value: {{webResponse.body.values.get(0)}}
The attributes for the first values record: {{webResponse.body.values.get(0).attributes}}
The first attribute for the first values record: {{webResponse.body.values.get(0).attributes.get(0)}}
The objectTypeAttributeId for the first attribute for the first values record: {{webResponse.body.values.get(0).attributes.get(0).objectTypeAttributeId}}
If those all work as expected, let's try nesting the iterators:
{{#webResponse.body.values}}
{{#attributes}}
{{#if(equals(objectTypeAttributeId, "277"))}}
{{objectAttributeValues.value}},
{{/}}
{{/}}
{{/}}
Note I also changed to the other format of equals() function to force the evaluation of the objectTypeAttributeId before the conditional test.
That works very well. Thanks for the good explanation. I think I understand the thing better now. Even if I do not understand what was wrong with my syntax. The official documentation is lacking a lot of practical explanations.
BR Christof
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
AND this is super fast. A dataset with over 100 objects is processed in 3 seconds. Thanks again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From what you show, I believe "value" should be plural "values" at that top level:
{{#webResponse.body.values.attributes}}...
And, you may need to incrementally test filtering to get your value, writing to the audit log to test the results.
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.
Thanks, in the automation it's correct with values. but I do not get any results so the audit log is empty and I still do not know, how to build the correct JSON path or loop.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.
Register nowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.