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,368,022
Community Members
 
Community Events
168
Community Groups

changing system select field value to set other custom fields as required in jira using behaviour

Edited

selecting a single value in system select field-"Resolution" have to set multiple custom fields as required..

selecting a single value in custom select fields "Defect Category" have to set multiple system fields as required.. are working but not the vice versa

CustomFields

  • Defect Category
  • Technical Cause Resolution Issue.PNG

 

1 answer

1 accepted

0 votes
Answer accepted
Vikrant Yadav Community Leader Jan 13, 2022

Hi @Ravi Kanth For setting custom field Defect Category and Technical Cause mandatory based on Resolution system field. For this you have to apply Server side script on Resolution field and apply the following script. Kindly change field id and Resolution name in If/else statement. 

hope it works for you!

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

def resolutionField = getFieldById("resolution")
def fixVersionsField = getFieldById("fixVersions")
def defect = getFieldById("customfield_12345")
def technical = getFieldById("customfield_78910")


def resolution = resolutionField.getValue() as Resolution

if (resolution.name == "Fixed") {
fixVersionsField.setRequired(true)
defect.setHidden(false)
technical.setHidden(false)
} else {
fixVersionsField.setRequired(false)
defect.setHidden(false)
technical.setHidden(false)
}

 Thanks

V.Y

Hi@Vikrant Yadav ,

Thank u soo much...
the code works  but when reverting back the selection to "Please Select.." custom Field still remains as mandatory.Resolution-Issue.PNG

Vikrant Yadav Community Leader Jan 13, 2022

@Ravi Kanth May i know Please Select is a value you added to Resolution field ? If Yes, try to add "Please select.." in else statement. 

else if (resolution.name == "Please select.." ) {
defect.setRequired(false)
technical.setHidden(false)
}

 Usually Default value comes for mandatory Resolution field.It seems that you added Please Select... value in Resolution. 

Let me know, how it works.

Thanks

V.Y

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events