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.
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
What I tried so far:
GET Role PO (/rest/api/3/project/{{project.id}}/role/12067)
↓
GET Role SM (/rest/api/3/project/{{project.id}}/role/12064)
↓
Advanced Branch:
{{webResponses.body.actors.actorUser.accountId}}
↓
GET Admin API (https://api.atlassian.com/admin/v2/orgs/{orgId}/directories/{directoryId}/users/{{getAccountId}})
↓
Condition:
{{webResponse.body.data.status}}
↓
Send Email:
{{webResponse.body.data.email}}
ELSE
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.
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:
I could not identify a reliable way to remove duplicated users
the array/string behavior in Jira Automation seems inconsistent
The most stable workaround I found so far was:
{{allAccountIds.split(",").removeEmpty().distinct()}}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:
active/inactive status
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!
Hi @Raissa Nepomuceno Epaminondas
Welcome to the community forums!
This was quite an interesting and challenging scenario. I wasn't able to find an out-of-the-box solution without using REST API requests with Automation for Jira, so that the approach will use a few different endpoints.
My tested configuration example is shown in the captures below. Just consider the proposed solution uses a single project role, but that can be changed later on if needed, adding new variables and a final one to compound all the extracted members' account IDs.
I hope this helps you as a guideline!
- Pablo Vergara / SSE - ServiceRocket
Hello @Raissa Nepomuceno Epaminondas
As far as I can see on a first look, getAccountId is empty because you are retrieving
{{webResponses.body.actors.actorUser.accountId}}
instead of
{{webResponse.body.actors.actorUser.accountId}}
the API call on the automation returns webResponse, without the 's'. In fact, I can see that you are properly using it on the rest of the flow, so it should work as expected then.
On the other hand, I'm not 100% sure that Automation for Jira maybe can't do that data process that you require. Specially the status checks and the deduplication.
If you are familiar with Forge, a small Forge app would fit greatly. If not, maybe you could develop some Python script on a Jenkins job or similar and run it as a service.
Regards!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Marcos Sanchez !
However, because I needed to merge the results from both Project Role requests, Atlassian Support recommended using webResponses (with “s”) to access all previous web request responses together inside the same rule and webResponses.body is actually returning data correctly from both requests.
I added a Log Action with:
webResponses Body: {{webResponses.body}}
So at this point I believe the challenge is more related to how Jira Automation handles array parsing / iteration from merged webResponses rather than the API response itself.
I also agree with your point that Automation may not be the ideal tool for this level of data processing and deduplication logic. :/
Thanks a lot for your help and insights!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.