How can I iterate over a smart value list's element's property to see if it is equal to smart value?

Nathan Given
Contributor
November 22, 2024

In my Jira automation I have a webhook that returns this JSON:

{ "entities": [ { "id": "1", "displayName": "Display name 1", "description": "" }, { "id": "2", "displayName": "display name 2", "description": "" } ] }

I'm trying to iterate over every "entity" to see if the "displayName" value equals my Jira automation smart value, {{displayNameCheck}}

I've managed to get it to kind of work by hard-coding the value of {{displayNameCheck}} into my if statement, but I can't seem to get it to work with the smart value.

Here is what is working:

 

{{#webhookResponse.body.entities}} {{#if(equals(displayName, "Display name 1"))}} {{.}} {{/}} {{/}}

 

However, I don't want to hard-code "Display name 1" into my if statement. I want to use {{displayNameCheck}}.

 

However, 

{{#webhookResponse.body.entities}} {{#if(equals(displayName, displayNameCheck))}} {{.}} {{/}} {{/}}

does not work.

Nor does:

 

{{#webhookResponse.body.entities}} {{#if(equals(displayName, {{displayNameCheck}}))}} {{.}} {{/}} {{/}}

 

I've tried using advanced branching, however, advanced branching has a restriction on isolation (any changes in the branch won't be visible in the main rule), and I need to pass variables around to perform some API calls later in the automation ( link )

 

Is there any way to accomplish what I'm trying to do (iterate over a JSON array to see if one of the element properties equals my existing smart value)?

Thank you,

Nathan

1 answer

0 votes
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 23, 2024

Hi @Nathan Given 

Can you try this?

{{#webhookResponse.body.entities}}
{{#if(equals(displayName, ^displayNameCheck))}}
{{.}}
{{/}}
{{/}}

 As far as I know, the ^ symbol is used to access variables/smart values outside the context.

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