Hello all
I am looking to use Automation for Jira to set the Approvers to all members of a project role, but https://support.atlassian.com/cloud-automation/docs/jira-smart-values-projects/ seems lacking this particular case.
I assume I would need to set up a variable and use a smart value? Any hints on how to achieve this? The "Edit issue" action only supports users and copying values from existing issues.
Many thanks in advance!
One way to do this would be to call the REST API from a rule to gather the accountId values of people in the role, and then assign them as approvers with a JSON edit.
If you want to try that, here are some references to help:
Kind regards,
Bill
Hi, Fabian.
You are close with that starting point...you will need the JSON for a multi-select user field and the account id values from the response using with an iterator.
{
"fields": {
"Approvers": [ {{#webResponse.body.actors}} { "id":"{{actorUser.accountId}}" }{{^last}}, {{/}}{{/}} ],
}
}
If that does not work, please try writing the expression to the audit log to see what is happening.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Bill Sheboy
Many thanks for providing the iterator! Unfortunately Automation for Jira claimed, the output is not a valid JSON...So I ran it through a JSON validator and seems the very last comma after the square bracked was the culprit, removed it and voilà: Issues edited successfully!
This is the working expression based on your response:
{ "fields": { "Approvers": [ {{#webResponse.body.actors}} { "id":"{{actorUser.accountId}}" }{{^last}}, {{/}}{{/}} ] }}
Thanks again for your support, we made it work in true community fashion so cheers to that :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well done, and that is interesting! I have found the rule parsing inconsistent in accepting a trailing comma for updates.
Please note I added the conditional processing with {{^last}}, {{/}} handling as I know extra commas inside the list items fail.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, @Fabian Dengel !
If you`re ok with Jira plug-ins, try out Business Process Manager. My team has developed this plug-in to manage and optimize complete processes involving different departments and several operations.
Read more about the approval process in BPM in the article or our documentation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the proposal, as you can see we managed at least my use-case with out-of-the-box tooling :)
On that note: I was going to try your app, but it seems your demo does not work (at least when I opened the demo link https://saasjettest.atlassian.net/plugins/servlet/ac/bpm-demo/bpm-main-page-demo?project.key=BPM&project.id=10007 it ran into an error)
Have a good day and kind regards
Fabian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Bill Sheboy
Many thanks for your support, much appreciated!
I was able to create the request and retrieve the project role members, however I am stuck at transforming the returned accountIds into a usable JSON to populate the Approvers.
Could you give me another hint on this one?
First, I am creating a smart value variable "roleMembers" from the web request like this:
{{webResponse.body.actors}}
When I log the value of this request I receive the following (accountIds obfuscated, but syntax identical):
{id=12951, displayName=Fabian (TEST EXTERNAL), type=atlassian-user-role-actor, actorUser={accountId=qm:xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx:xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx}}, {id=12952, displayName=Fabian (TEST), type=atlassian-user-role-actor, actorUser={accountId=qm:xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx:xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx}}, {id=12953, displayName=Fabian Dengel, type=atlassian-user-role-actor, actorUser={accountId=xxxxxxxxxxxxxxxxx}}
How would I need to transform this in the EDIT action to be accepted?
{
"fields": {
"Approvers": "{{roleMembers")}}",
}
}
I fiddled around with ".asJsonObject" and ".asJsonArray" but my knowledge in that area is lacking and I could not get it to work. I feel I am close, but no cigar :)
Thanks again for pointing me in the right direction!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.