Set Priorities Based on the Issue Type

srinivas vadlamudi October 19, 2023

Hi guys,

I need help. We have a requirement to set priorities based on the issue type. We are using the JIRA Server 8.20.12 version now. I have written this below code for the Task issue type. It's working fine on the Create screen But not on the edit screen. Can u help me to find a solution for this?

import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.PRIORITY
def constantsManager = ComponentAccessor.getConstantsManager()
def formField = getFieldById(PRIORITY)
def availablePriorities = ["High","Low"]
if(issueContext.issueType.name == "Task")
{
formField.setFieldOptions(availablePriorities)

}

1 answer

0 votes
Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 19, 2023

@srinivas vadlamudi -

Out of the box, you can set priority scheme at the project level in the Server env.  However, the scheme is for the entire project and cannot be based on issue types used within a project.

To set priority at issue type + only in the EDIT screen, you will need to use third party paid add-on to accomplish the ask - Example Scriptrunner for Jira and utilize their Behavior component setup -

https://marketplace.atlassian.com/apps/6820/scriptrunner-for-jira?hosting=datacenter&tab=overview

NOTE - I hope you have already migrated to Data Center env and not staying with the Server env, it is because the Server env support will end at Feb, 2024.

Hope this helps.

Best, Joseph Chung Yin

Jira/JSM Functional Lead, Global Technology Applications Team

Viasat Inc.

Kenneth Hoff
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 30, 2024

I had this same issue. I ended up adding the issue type field to screen and hiding it with the behavior. You just have to remember to have this as well so that the field shows on the create screen:

import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE

def issueTypeField = getFieldById(ISSUE_TYPE).setHidden(true)

if (!underlyingIssue){
issueTypeField.setHidden(false)
}

Although I couldn't get the priority field to set the options the same way as this. Maybe it changed. I'm on Data Center version 9.16.1.

Suggest an answer

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

Atlassian Community Events