How to get the 'Free Text Field' type custom field value and set it as required field?

Dear all,

During I using the JIRA Behaviours Plugin to add some validations for some custom fields, I found that for 'Select List' type or 'Text Field' type, use following script code can work:

==================================================================================

FormField AField = getFieldByName("External Party") // this is a select list type field

FormField BField = getFieldByName("DEV Remark") // this is a text field type field

BField.setRequired(false)

if ((AField.getValue() != null) && (BField.getValue() == "")){

BField.setRequired(true)

}

===================================================================================

but, for 'Free Text Field' type field, use upper code to check, it seems can't work:

e.g. CField is a 'Free Text Field' type field, uses 'CField.getValue()' to get the input value in it, even the field contains the input value, 'CField.getValue()' still return null, and use following method to this field, it also has not any show or prompt:

CField.setRequired(true)

CField.setError("test error")

For this case, may I ask that about 'Free Text Field' type custom field, how to get its input value and how to set it as require / set error to it? thanks.

1 answer

0 vote

Instead of checking for empty strings and nulls just use "groovy truth" - ie:

if (AField && ! BField)

instead of what you have written. Empty strings and null both evaluate to false in that context.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

137 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you