Automation For Jira - How to write a rule to set the Advanced Roadmap Team Field
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Currently, Automation For Jira does not support fields which are coming from Advanced Roadmap, such as the Team, Target Start, Target End fields. Because of that, it is not possible to easily set these fields when using the Edit Issue action, because these fields are not listed in the Choose fields to set... dropdown. This limitation is tracked in the feature request linked below:
- JIRAAUTOSERVER-159Getting issue details... STATUS
Another challenge with the Team field is the fact that it only stores the Team ID in the database instead of the Team name, which makes it difficult to write a rule to edit this field, when using Smart Values.
This article explains how to configure a rule to set the Team field by using Smart values instead of using the Choose fields to set... dropdown.
Environment
- Jira Server / Data Center 8.0.0 and any higher version
- Automation for Jira 7.0.0 and any higher version
Solution
Let's assume that you are trying to write an automation rule that will automatically set the Team field when a new issue is created, and based on the value of another field (for example the Priority field). The solution below explains how to implement a rule that covers this use case, but feel free to modify it based on your own use case.
Please note that the Team field cannot be set for a sub-task issue, since this field is automatically inherited from the parent issue of the sub-task. Therefore, the solution suggested does not apply to sub-tasks.
Step 1 - Get the Custom Field ID of the Team field
Each Jira installation will have its own set of custom field IDs. Therefore, this step is required, since the Team field ID might differ across Jira installation.
To get this ID:
- Go to the page ⚙ > Issues > Custom Fields
- Look for the Team field, then click on ... > View next to the field
- Get the ID found in the URL (in the example below, the ID is 10204):
Step 2 - Get the list of Team names and their respective IDs from the Database
Log into the Jira Database, and run the following SQL query to get the list of Team names and their respective IDs:
select * from "AO_82B313_TEAM" where "SHAREABLE" = true;
Note that this SQL query was written and tested for PostgreSQL. For any other type of Database, please remove the double quote characters from this query before executing it.
Example of result:
In the example above, there is only 1 team, with name "SCRUM board Team", and ID 1.
Step 3 - configure the automation rule
Let's assume that you are trying to write a rule to set the Team field to "SCRUM board Team", if the Priority field is set to Medium. In this case, the rule will be configured as shown below:
- Trigger:
- Issue Created
- If/else block:
- Use the condition "Priority equals medium"
- Action: Edit Issue.
- Select More Option instead of of the option Choose fields to set..
Paste the content below in the Additional Fields section. You will need to change 10204 with the Team field ID in your Jira instance, and change 1 with the Team ID of your choice:
{ "fields": { "customfield_10204":"1" } }
If you have more than 1 Team (which is likely to be the case), you can add as many ELSE blocks after the IF block as Teams you have. Then, for each ELSE block:
- change the condition to another Priority value (or another value for the field you are choosing to decide which Team the ticket should be assigned to)
- change the formula in the Additional Fields by using the right Team ID