Automation For Jira - How to write a rule to set the Advanced Roadmap Team Field

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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-159 - Provide Support for Portfolio/Advanced Roadmaps for Jira fields (Team, Target Start, Target End)

Another challenge with the Team field is 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.

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.

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):

    Find ID of TEAM field from url

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:

1 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:

Output of sql command fetching list of teams where shareable = true

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:

      1 2 3 4 5 { "fields": { "customfield_10204":"1" } }
      Set team field using automation

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

Updated on June 7, 2024

Still need help?

The Atlassian Community is here for you.