Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Automation Edit Issue component advanced conditional logic

Ben Alderton April 17, 2024

Hello, my use case is to set a user from a single user picker as a request participant on the condition their email domain matches "xyz.com". I have tried different expressions and it seems the "if" block never passes. This it to check if the user is a portal-only customer (added with email address) or a service desk customer (generated from AD).

{
"fields": {
"request participants": [
{
"id": "{{#if(contains(issue.customfield_10274.emailaddress, "xyz.com"))}}{{issue.customfield_10274.emailaddress}}{{else}}{{issue.customfield_10274}}{{/}}"
}
]
}
}

I use an automation rule to add a user as a participant which works fine for service desk customers but not with portal-only customers as some seem to only have their email as their display name, and others have first name, surname, which would need to be parsed as user.emailaddress to be successful in adding them with "id" : value"" if I'm not mistaken, as they don't have an id.

 

Any advice would be greatly appreciated.

 

 

 

1 answer

1 accepted

0 votes
Answer accepted
Ben Alderton July 9, 2024

I managed to solve this a while back. closing this in case someone else inexperienced like myself has a similar use case and issue. The issue was likely that I wasn't trimming the 

I use the "Web Request" component to query users based on information extracted from the ticket "https://jira.atlassian.net/rest/api/latest/user/search?query={{issue.summary.substringAfterLast("-").trim().urlEncode}}", I then loop through the results using the "For Each" branching component "{{webResponse.body.first}}" creating nested variable "webResponseResult". I then create a second nested variable called "EmailorID" which has the conditional logic value of "{{if(webResponseResult.emailAddress.isEmpty,webResponseResult.accountId, webResponseResult.emailAddress)}}". This will return either an account id or email address, as some Atlassian accounts will have their preferences set to hide their account email address which affects the query results.

Then I use an "IF smart value" component to check if the web response result variable matches the queried name."{{webResponseResult.displayName}}" contains "{{issue.summary.substringAfterLast("-").trim()}}"

Finally I add the variable using the advanced edit with the following syntax.
"{
"update": {
"Request participants": [{
"add": {"id": "{{EmailorID}}"}
}]
}
}"

I also used accountid instead of id for setting the user picker customfield, as it seems to impact the structure if it's an email for the user picker instead of id.

"{
"fields": {
"customfield_10189": [{
"accountId": "{{EmailorID}}"
}]
}
}"

Hope this might help someone else.

Suggest an answer

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

Atlassian Community Events