Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using Behaviours to set a field as required when updating an issue

Filzah Aziz June 30, 2020

I'm trying set customfield1 to required only when customfield2 has a value in it. Customfield2 is a single line text fields, whilst customfield1 is a select list option. Here is what i've written so far in the server-side script which does not seem to do anything. Also note that this action should be triggered during edit screen and not through a workflow transition. What am I doing wrong?

 

com.atlassian.jira.issue.fields.CustomField

def customField = getFieldById("Entrance") // custom field main entrance
def customField2 = getFieldById("Entrance  Number Tag") // custom field main entrance  number tag

if(customField2 ==!null)
{ customField.setRequired(true)
customField.setHelpText("Please change this to Done")}
else
{ customField.setRequired(false)}

 

1 answer

1 accepted

0 votes
Answer accepted
Filzah Aziz July 1, 2020

Managed to get this sorted by adding an initialiser. Here is my script:

def customField = getFieldByName("Entrance") // custom field main entrance rotterdam kralingen
def customField2 = getFieldByName("Entrance Number Tag") // custom field main entrance rotterdam kralingen number tag

customField2.setRequired(customField.getValue() == 'Done')

Suggest an answer

Log in or Sign up to answer