Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to restrict priority values on edit?

BrianB October 7, 2015

I've only used groovy scrips in workflows, but I have a requirement to restrict users from editing the priority AFTER creation to only certain priority values. Obviously they can do this any time after the Open transition

7 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Kristian Walker _Adaptavist_
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, 2015

Hi Brian,

 

You can try downloading version 0.5.10 of Behaviours from the marketplace.

 

Thanks

 

Kristian

1 vote
Kristian Walker _Adaptavist_
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 9, 2015

Hi Brian,

 

This can be done using the Behaviours plugin by applying the following code below as a behaviour to to the Priority field. You will also need to add a condition which states Except - Workflow Action = Create.

This will then mean that all the priorities will be available when an issue is created but only certain priorities specified will be available during all other statuses in the workflow.

 

import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.PRIORITY

// Check if the Issue is in the Create transition and if false restrict the priorities available
if (getActionName() != "Create") {
    def constantsManager = ComponentAccessor.getConstantsManager()
// Only show priorities which have an ID greater than 2   
 def allowedPriorities = 	constantsManager.getPriorityObjects().findAll {
        it.id.toInteger() > 2
    }.collectEntries {
        [(it.id): it.name]
    }
    getFieldById(PRIORITY).setFieldOptions(allowedPriorities)
}

 

Thanks

 

Kristian

 

0 votes
BrianB October 19, 2015

Unfortunately, we are in JIRA 6.1.6 and 2.1.16 is the highest version we can use.  is there an older version of behavior plug-ins we can install?

0 votes
Kristian Walker _Adaptavist_
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 15, 2015

Hi Brian,

Behaviours was merged with Script Runner in version 3.0. In order to be able to implement the code above using behaviours then you will need to upgrade to  a version of Script Runner greater than 3.0.

Thanks

Kristian

0 votes
BrianB October 15, 2015

I don't see it. I have script runner 2.1.16. I'm guessing I need to upgrade

0 votes
Kristian Walker _Adaptavist_
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 14, 2015

Hi Brian,

You are correct in stating that Behaviours comes with Script Runner. If you install Script Runner into your JIRA instance you will notice that you get the Behaviours link appear on the left hand side of the screen under Administration > Add Ons.

 

Once you navigate to this link you will then be able to set up a new behaviour set with a mapping to your project(s) and Issue Type(s).

 

Thanks

Kristian

0 votes
BrianB October 14, 2015

Thanks for your response Kristian.  The Behaviors plugin has been merged with Scriptrunner.  I'm not seeing how to apply the behavior to a system field. Outside of workflows, I have not used scriptrunner

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events