Sort Organizations field in Queues with Automation for Jira

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

Summary

Sometimes when you're trying to group tickets by the same Organization without having to filter them in the Queue, you discover that Jira doesn't support ordering the JQL by Organizations field. The following Feature Request is opened and related to this problem: JSDCLOUD-4548 - [Field Organization is not sortable in a JQL - REVIEWING]

Solution

Since it's possible to order a Custom Field created in Jira Service Management, we can achieve the above goal by copying the values from the Organizations to a new Custom Field. For that, you can follow the below instructions:

Requirements

  1. Create a Label custom field following the steps in Create a custom field and add it to your screens.

  2. Create a new automation rule following the steps in Create and edit Jira automation rules

Automation rule configuration

Trigger

For the trigger, you will need to select the Field value changed trigger and select Organizations in the Field to monitor for changes. This will allow us to get and update the values whenever an issue is created or updated.

Field value changed trigger and "organizations" added in "fields to monitor or changed"

Action: create a variable

Now, create a new action and select Create variable action; This action will get the values from the Issue and we'll use a function to replace the spaces with underscore.

Information

The .replace() function is necessary because Jira won't allow you to use spaces when you're inserting a label.

Create a variable using smart value to fetch organizations name

Organization Smart value

{{issue.Organizations.name.replace(" ", "_")}}

Action: Edit issue

Once you configured your variable, it's time to create a new action and select Edit Issue but it won't be necessary to select fields in the Choose fields to set... dropdown.

Use the More options and uncheck This rule should send emails. Rule actor must be an admin or project admin. if you don't want to receive emails whenever this action is performed.

Now, copy and paste the JSON below replacing the "<Label-CustomField>" with the name of your custom field and use the smart value as it's shown in the code block.

Information

The .split() function is used to separate the values from the Organization's name;The .asJsonStringArray() function is used to parse the values as a valid JSON array.

Additional fields JSON

{"fields": {"<Label-CustomField>": {{Orgs.split(", ").asJsonStringArray}}}}

Edit issue component in jira automation using additional fields to set Org group field

You can learn more about the JSON Functions used in this article in the article below:

Queue configuration

Once your automation rule is configured, you need to add the custom field you created to your queue.

You can drag and drop your queues in the sidebar to order them, or edit a queue to change its name, requests filtered and columns that appear.

You need to be a project admin to edit a queue.

To edit a queue:

  1. From your service project, go to Queues.

  2. Select the queue you want to edit.

  3. On top-right of your page, select ... (three dots) > Edit queue.

  4. Edit Name, Issues to show, Columns. Note that you will see a live preview of the updated issues that appear in this queue as you edit it.

  5. In Columns, add the custom field you created.

  6. Select Save to confirm your changes.

More details in Edit queues documentation.

The result should be something similar to this:

Sorted Org groups in JSM queue

Updated on July 11, 2024

Still need help?

The Atlassian Community is here for you.