Hi all,
I'm trying to save some time and write a unique statement to create a variable from a webResponse.
Background: I want to add the user that opens a PR in our BB (Data Center version) to a multi user picker custom field in our Jira (Cloud).
When a PR is created I get a webhook response from BB, including the 'pull request actor' (which is a displayname, sort of, and in our cases always matches a Jira user displayname value).
Then I send the PR actor to Jira Cloud API groupuserpicker, which usually returns many users, as it partially matches any of the given terms.
So I want to parse that response and get the correct user, which is, of course, the one that matches my PR actor displayname (plus another check that I do on the email, to avoid possible duplicates/false positives).
I created a new variable using this code:
{{#webResponse.body.users.users}}{{#if(and(equals(displayName.trim(),"Federico Boldrini")),html.match("([a-zA-Z0-9\.\-]+\@mycompany\.com)"))}}{{accountId}}{{/}}{{/}}
, which works perfectly. but only for myself of course :)
Then I changed it to this:
{{#webResponse.body.users.users}}{{#if(and(equals(displayName.trim(),{{prActor}})),html.match("([a-zA-Z0-9\.\-]+\@mycompany\.com)"))}}{{accountId}}{{/}}{{/}}
, where {{prActor}} is a variable that I previously created from the BB response.
And I started to get errors like:
Error rendering smart-values when executing this rule:
Parameters not closed: (displayName.trim(),{{prActor: {{#webResponse.body.users.users}}{{#if(and(equals(displayName.trim(),{{prActor}})),html.match("([a-zA-Z0-9\.\-]+\@mycompany\.com)"))}}{{accountId}}{{/}}{{/}}
I tried to remove the enclosing {{}}, and the result was an empty variable.
I'm wondering whether it's possible to use an 'external' variable within an if/equals statement. Alternatively, I was thinking about using concat to add the prActor value to the groupuserpicker webResponse, and then use String comparison checks. But I hate, when I have (again, and again) to transform json stuff into string to 'make it work'....
Because for now, I'm using advanced branching to split the groupuserpicker webResponse and then I use the conditional check "Compare two values", which works fine, but has a problem: the branch is processed 'at a random time' within the automation, so I can't be sure that it will process the branched code before other (previous...!) parts of the automations are processed.
Thanks in advance!