How do I configure an automation rule to set the Teams value based on assignee?
Asked by Jennifer Maurer:

I have found similar questions, but the issue may be that I am using Jira Data Center v9.4.15, not Cloud.

I have configured four shared teams in Advanced Roadmaps. I have added the Teams field to my screens. I can manually set the Team value in either Plans or issue screen. My goal is have an automated way to make sure the Team value is always set going forward.

I created a rule triggered when an issue is assigned to a user. If assignee is (a, b, c) then edit Team field to (Team ABC). The issue is that the Team field is not available to be selected in the Edit Issues fields pick list. It is cf(10502) according to the custom fields list.

Please help!


Answers:
author: Bill Sheboy
body: Hi [@Jennifer Maurer](/t5/user/viewprofilepage/user-id/5093000)

*First thing, I am using Jira Cloud, and so my suggestions are based on what I know about automation, in general. With that out of the way...*

I believe you may [set that field using advanced edit with JSON](https://jira.atlassian.com/browse/JIRAAUTOSERVER-159), in the "More options" section of the Edit Issue action. To learn more about such edits, please look here: <https://confluence.atlassian.com/automation/advanced-field-editing-using-json-993924663.html>

For teams, please try this:

```
{
  "fields": {
    "Teams": "the id value for the team"
  }
}
```

You will need to find the team id values using example issues, such as with this how-to article, and then searching for the field's value: <https://confluence.atlassian.com/automation/find-the-smart-value-for-a-field-993924665.html>

Kind regards,  
Bill

comments: author: Jennifer Maurer
body: Thank you very much for the info; this worked!


author: Jack Brickey
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) , as always, thanks for your expertise in Automation. I am missing the bit on how this works based on assignee though. I have a use case where I want to keep the Team field updated based on Assignee changing.

[@Jennifer Maurer](/t5/user/viewprofilepage/user-id/5093000) , could you share your full automation so that I, and others can benefit?

I suspect where my use case may be different is that I don't want to create a "hard-coded" scenario in my automation where team members are concerned. Rather I want to lookup the assignee and find the team they are assigned to and then set the Team accordingly. Assuming this "lookup" is even possible, there is one remaining gottcha - what happens when a user is in multiple teams? I want to test that out to see.


author: Jennifer Maurer
body: [@Jack Brickey](/t5/user/viewprofilepage/user-id/853369) I have four of these branches in my rule, one for each set of team members.

![Screenshot 2024-07-03 at 3.40.32?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/333388iDF2C771B81814BCF/image-size/large?v=v2&px=999 "Screenshot 2024-07-03 at 3.40.32?PM.png")


author: Jack Brickey
body: Thanks [@Jennifer Maurer](/t5/user/viewprofilepage/user-id/5093000) , that is what I expected. The one obvious challenge here is keeping the rule up to date. If changes are made to one of the Teams the rule will need to change. Hopefully we will get a way to search for any team(s) that a user is in one day.


author: Bill Sheboy
body: Yes, and...

For Jira Cloud, Server, and Data Center, I believe the if / else conditions are a high-maintenance solution. With Jira Cloud, a Lookup Table would make that slightly easier to maintain.

One would hope for a method to "find the teams for a user", but there is no REST API endpoint to do that yet. Here is the really old suggestion to add that, but it is tagged with the dreaded "future consideration": <https://jira.atlassian.com/browse/JSWCLOUD-20360>

Another approach would invert the query direction, and only need to hardcode the team id values. That would lookup the users for each possible team, one by one, check for membership, and then use that id. This is the relevant endpoint from the Teams REST API for those wanting to try that: <https://developer.atlassian.com/platform/teams/rest/v1/api-group-teams-members-public-api/#api-gateway-api-public-teams-v1-org-orgid-teams-teamid-members-post>


Tags: jira-data-center

teams