I'm trying to write an automation that uses a previously-defined variable, say {{specialClientId}}, to fetch other important data about this client from an online database. I'm having a bit of a problem with the variable scope inside the inner conditional.
In particular, I make a web request to an API endpoint that provides an output like this:
{"result": [
{"clientId": clientId1,
"clientFavAnimal": clientFavAnimal1,
etc},
{"clientId": clientId2,
"clientFavAnimal": clientFavAnimal2,
etc},
...
]
}
I want to extract the clientFavAnimal associated to my {{specialClientId}} variable.
My approach right now is to place a conditional inside a loop that iterates through the webResponse.body result, like so:
{{#webResponse.body.result}}
{{#if(equals(clientId,specialClientId))}}
{{clientFavAnimal}}
{{/}}
{{/}}
In my testing, this works perfectly if I write in the specialClientId explicitly, but this results in blank output when written as above. This makes sense to me because {{specialClientId}} is inside the loop, and so Jira thinks I'm referencing a key inside the webResponse result. How do I make the scope of the variables inside the conditional explicit so that the correct values are compared?