Hi everyone,
I’m trying to implement a Jira Cloud Automation rule to notify leadership users when the percentage of Bugs in the backlog exceeds a threshold.
The email recipients must be dynamically retrieved from Project Roles.
Main Requirement
The automation must:
Retrieve users from multiple Project Roles
Merge all returned accountIds into a single list
Remove duplicated users
Validate which users are ACTIVE
Retrieve email addresses only for ACTIVE users
Send emails only to ACTIVE users
If ALL users are inactive, send email to a fallback user
Current Automation Logic
What I tried so far:
<strong>GET</strong> Role PO (/rest/api/3/project/{{project.id}}/role/12067)
↓
<strong>GET</strong> Role SM (/rest/api/3/project/{{project.id}}/role/12064)
↓
<strong>Advanced Branch</strong>:
{{webResponses.body.actors.actorUser.accountId}}
↓
<strong>GET</strong> <strong>Admin API </strong>(https://api.atlassian.com/admin/v2/orgs/{orgId}/directories/{directoryId}/users/{{getAccountId}})
↓
<strong>Condition</strong>:
{{webResponse.body.data.status}}
↓
<strong>Send Email</strong>:
{{webResponse.body.data.email}}
<strong>ELSE</strong>
Send email to fallback userUnfortunately, this is not working correctly.
Inside the Advanced Branch, {{getAccountId}} is coming empty in my environment.
Because of that, the Admin API request becomes:
/users/
instead of:
/users/{{accountId}}which causes the API to return the first page of users from User Management.
After investigating with Atlassian Support, I now understand why this behavior happens.
Additional Attempts
I also tested:
{{ActorsAccountIdPO.concat(ActorsAccountIdSM)}}but the variables seem to behave like strings instead of arrays.
Result example:
[id1][id2],[id3]
instead of a proper merged list.
I also tried a simpler merge approach:
{{accountIdPO}},{{accountIdSM}}This worked partially for iteration purposes, but:
The most stable workaround I found so far was:
{{allAccountIds.split(",").removeEmpty().distinct()}}
Important Constraint
I cannot use:
/rest/api/3/user?accountId={{getAccountId}}because in our Jira Cloud environment the emailAddress field is NOT returned due to privacy restrictions.
Because of this, I had to use the Admin API instead:
https://api.atlassian.com/admin/v2/orgs/{orgId}/directories/{directoryId}/users/{{getAccountId}}since this endpoint returns:
email
active/inactive status
Main Question
Is it actually possible to implement this logic reliably using only Jira Automation Cloud?
More specifically:
What is the best pattern to merge accountIds from multiple Project Role requests?
How can duplicated users be removed safely?
What is the best approach to validate only ACTIVE users?
How would you implement the fallback logic if ALL users are inactive?
Or would you recommend another approach instead, such as:
Forge
External API/service
Any guidance or architecture suggestions would be greatly appreciated.
Thanks!