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

Behaviour to make a Multi-Select Field required based on another fields

Ryan Bullock March 27, 2024 edited

Hello,

I have been trying to set a Multi-Select field as required based on the value of another field. I can get it working for other fields, but struggling with Multi-select.

In this example, for non-multi-select: If 'Release Notes Status' = 'Include - Finalized', then 'Release Notes Title' is required. How do I tweak it for multi-select fields?

Script on 'Release Notes Status' field:
def ReleaseNotesStatus = getFieldById(fieldChanged)
def additionalInfo = getFieldByName("Release Notes Title")
def option = "Include - Finalized" // the option you want to check
def errorMsg = "Required" // the error message you want shown
if (ReleaseNotesStatus.value == option) {
if (!additionalInfo.value) {
additionalInfo.setError(errorMsg)
}
} else {
additionalInfo.clearError()
}
Script on 'Release Notes Title' field
def cf = getFieldByName("Release Notes Title")
if (cf.value) {
cf.clearError()
}

1 answer

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _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.
March 28, 2024

Hi @Ryan Bullock 

If you want to do this for a Multi-Select field, your if condition try something like this:-

def ReleaseNotesStatus = getFieldById(fieldChanged)
def releasetNotesStatusValue = ReleaseNotesStatus.value

def additionalInfo = getFieldByName('Release Notes Title')
def additionalInfoValue = additionalInfo.value

additionalInfo.clearError()

if (releasetNotesStatusValue = ['Option1', 'Option2', Option3'] && !additionalInfoValue ) {

    additionalInfo.setError("Sample Error Message")

}

Hope this helps to solve your question. :-)

I am looking forward to your feedback.

Thank you and Kind regards,

Ram 

Ram Kumar Aravindakshan _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.
April 7, 2024

Hi @Ryan Bullock

Has your question been answered?

If yes, please accept the answer.

Thank you and Kind regards,

Ram

Ryan Bullock April 8, 2024

Hi @Ram Kumar Aravindakshan _Adaptavist_

I will mark this as accepted, as the script works. However, it is a bit buggy. Sometimes the field will be marked as required, sometimes it doesn't.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, team '25, conference, certifications, bootcamps, training experience, anaheim ca,

Want to make the most of Team ‘25?

Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.

Learn more
AUG Leaders

Upcoming Jira Events