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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,557,826
Community Members
 
Community Events
184
Community Groups

Scriptrunner behaviour - set field mandatory if specifics values selected in priority system field

Edited

Hi, 

I'm new in scriptrunner and i need help to create a behaviour to set a field mandatory if priority is "high". But the script does not work. 

 

import com.atlassian.jira.issue.priority.Priority

def priority = getFieldById("priority")
def justificacion = getFieldById("customfieldid_15801")

if (priority == "High") {
justificacion.setRequired(true)

}
else {
justificacion.setRequired(false)
}

Thansk!

 

Maybe something like this but whit priority

 

import com.atlassian.jira.issue.resolution.Resolution

def resolutionField = getFieldById("resolution")

def fixVersionsField = getFieldById("fixVersions")

def resolution = resolutionField.getValue() as Resolution

if (resolution.name == "Fixed") {

fixVersionsField.setRequired(true) fixVersionsField.setHidden(false) }

else {

fixVersionsField.setRequired(false) fixVersionsField.setHidden(true)

}

 

1 answer

1 accepted

1 vote
Answer accepted
Jia Jie
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 17, 2021

Hi @Celeste D_Alessandro ,

You'll need to get the Priority field value for the if-else condition. For example:

import com.atlassian.jira.issue.priority.Priority
import com.atlassian.jira.issue.IssueConstantImpl

def priority = getFieldById(getFieldChanged())
def selectedPriority = ((IssueConstantImpl) priority.getValue()).getName()

def justificacion = getFieldById("customfieldid_15801")

if (selectedPriority == "High") {
    justificacion.setRequired(true)

}else {
   justificacion.setRequired(false)
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events