Group members automation role

Fadi Shahwan January 6, 2025

Hello,,

I'm trying to achieve the below simple requirements since long time but I couldn't :)

let me know if you have any solution 

I have two fields group field "Assigned Group" and multi users field "Group Members".

I need to create an automation role triggered when "Assigned Group" is being filled with a group name and the action will be to return the group members in the filed  "Group Members". I tried multiple smart values but it is not returning any result.

assigned group.PNG

can i achieve this requirements through automation or if you have any solution using script runner ?

2 answers

0 votes
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 7, 2025

Hi @Fadi Shahwan 

 

You could use this following code in a Scriptrunner Action in your automation ? 

String groupFieldName = 'Assigned Group'

Group assigneeGroup =  issue.getCustomFieldValue(groupFieldName)

issue.update {

    setCustomFieldValue(groupFieldName, assigneeGroup.getMembers())

}

Regards

0 votes
Jakub Cieslak January 7, 2025

Hi there, it is possible, but might be a bit tricky! Here is how to do it:

 

  1. Generate and prepare your Authorization TOKEN:
    1. Go to your Atlassian account (from Jira level, click on your avatar in top right corner, and select Manage account link).
      Screenshot 2025-01-07 at 17.55.12.png

    2. From top menu, select "Security", scroll down, and click on "Create and manage API tokens" link there 
      Screenshot 2025-01-07 at 17.56.44.png

    3. Create a new TOKEN

      IMPORTANT
      Please note that a TOKEN, due to security reasons, can be valid for up to 1 year. After that time, you will need to generate a new one, and update your Jira Automation accordingly.

    4. Make sure to copy the value of your TOKEN somewhere, as it cannot be accessed again.

    5. Encode your <email>:<TOKEN> value into Base64 format, for that, I used this website called base64encode [dot] org (it seems I cannot link it here...)

      Example of what to encode (do not add any " or spaces, just use your e-mail address from Atlassian, then : symbol, and Authorization TOKEN that you just generated):

      info@example.com:TOKEN-VALUE-THAT-YOU-JUST-GENERATED

    6. After that, copy the result into a safe place, as we will need it for the next step. Please note that in the result, there should be no visible e-mail address or so, just a "random" string that is rather long.

  2. Find your URL:
    1. Identify your Jira instance URL, it will look similar to this, and we will need this <your_instance_name> part:
      https://<your_instance_name>.atlassian.net

      The simplest way to get that is to look at the URL of your Jira. In my example, my instance name is: "jiraxp".

    2. Identify the name of the User Group that you want to use for this automation, if you do not know for sure, go to Global Settings -> User management -> Groups and find the name.

      IMPORTANT
      I want this solution to work on free Jira instances too, not just the paid ones which support Project-level usergroups. This is why I am using here a global-level usergroups, not project-level usergroups!

      In my example, my global user group name is: "confluence-users-jiraxp"

    3. Update the following URL with your jira instance name, and desired usergroup:

      https://<your instance url>.atlassian.net/rest/api/3/group/member?groupname=<name of the global usergroup>

      In my example, it becomes: 

      https://jiraxp.atlassian.net/rest/api/3/group/member?groupname=confluence-users-jiraxp
  3. Create your Jira Automation:
    1. This is how an example structure of your Jira Automation could look like:
      Screenshot 2025-01-07 at 09.08.36.png

      1. "Send web request" part:
        1. Web request URL: https://<your instance name>.atlassian.net/rest/api/3/group/member?groupname=<global usergroup>

          In my example: https://jiraxp.atlassian.net/rest/api/3/group/member?groupname=confluence-users-jiraxp (do not use it, this URL will not work in your case, you need to use your instance name and user group!)

        2. HTTP method: GET
        3. Web request body: EMPTY
        4. Check / Enable checkbox: Delay execution of subsequent rule actions until we've received a response for this web request
        5. In Headers, you need one entry with:
          1. Key: Authorization
          2. Value: Basic <your prepared Authorization TOKEN from first step>

            IMPORTANT:
            The value of the "Value" field should include this "Basic" word at the front, then space, and then your prepared Authorization TOKEN.
        6. Here is a screenshot of how it looks on my end:
          Screenshot 2025-01-07 at 09.16.11.jpg
      2. "Create variable" part:
        1. Variable name: userstoassign
        2. Smart value: {{webResponse.body.values.accountId.join(",")}}

          IMPORTANT
          In Smart Value, do not forget about {{ and }} symbols, they are required to make it work.
        3. This is how it looks like on my end:
          Screenshot 2025-01-07 at 09.20.31.png
      3. "Edit issue" part:
        1. Select the desired multi user field in "Choose fields to set..."
        2. In the value below, write {{userstoassign}} and select smart value option from dropdown:
          Screenshot 2025-01-07 at 09.23.01.png
        3. In the end, it should look like this:
          Screenshot 2025-01-07 at 09.24.18.png

And that's it! It might look complicated, but it is doable! Next, save the rule, turn it on, and test. In case it doesn't do what you want, check the audit log of that specific rule, it can point to where/why it breaks. For me, there were a few authentication issues, but following the steps above should precent that.

Cheers & Good luck!

EDIT: Removed links, as it seems to generate issues...

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events