unable to set a multi line field mandatory when values are changed in a text field

Hi , I have two custom fields one is a select list and the other is multi line text field.  I need to make the multi line text field mandatory when the there is a change to the select list.

 

I added the following code using the behavior plugin at the select list field - It didnt work - Please help me out.

 

 

import org.ofbiz.core.entity.GenericValue
import com.atlassian.core.ofbiz.util.OFBizPropertyUtils    
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager 
def componentManager = ComponentManager.instance
FormField formComponent = getFieldByID(FieldChanged)
FormField psitre = getFieldById("customfiled_18292")
psitre.setRequired(true)



1 answer

HI Saravanan, 

The code below shows how to make a multi line text field mandatory when a select list has had an option selected using behaviours.

As the value will always change to another non value this will ensure that the multi line text field stays mandatory when the select list value field is updated on the create or edit screens.

// Get a pointer to both my fields
def demoSelect = getFieldByName("Demo Select List") 
def demoMultiTxt = getFieldByName("Demo Multi Line Text Field") 
// Get the Value of the Select List Field
def selectedVal = demoSelect.getValue()
if (selectedVal != null){
demoMultiTxt.setRequired(true)
}

 

Kristian

 

 

Thanks. I will try this out

Hi Kristian, Thanks for your help. The above hook fires even before the select list value is changed - can we change it in such a way only it fires when there is a change to the field value?? thanks Saran

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,019 views 12 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot