Forums

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

How to show/disable fields based on select list value through behavior?

Teja
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 3, 2018

Hi,

I am trying to enable some fields when Roadmap Item = Tactical [single select type] else the fields will be disabled. Can someone help me and i tried below code doesn't seem working. 

def dropDown = getFieldById("customfield_15200")
if (dropDown.getValue() == "Tactical") {

def ccgroup = getFieldByName("Name")
def ccgroup1 = getFieldByName("Solution")
def ccgroup2 = getFieldByName("Theme/s") //Group
def ccgroup3 = getFieldByName("Driver Category")

ccgroup.setReadOnly(false)
ccgroup1.setReadOnly(false)
ccgroup2.setReadOnly(false)
ccgroup3.setReadOnly(false)
}

 Thanks

Teju Naik

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 7, 2021

Your issue might be just with the "def myCustomField" line.

If you look carefully, you will see that you are calling "getCustomFieldObjectsByName", the plural on "Objects" means that you can potentially get more than one custom field with this method. Even when you only have 1 custom field that matches that name, you will still get a collection or array of custom fields and you have to identify which item in the collection is the custom field you care about.

If you are 100% sure that you only have 1 custom field with that name, you can just get item 0 from the collection.

def myCustomField = customFieldManager.getCustomFieldObjectsByName("Custom multi-user field")[0]
WellSky IT
July 7, 2021

Peter-Dave...is it possible to be so happy and so mad at the same time?  Because those 3 characters "[0]" just made me into a WINNER!  Next time you are in KC I owe you a beverage.  Thank you sir.  Consider your answer...ACCEPTED!  

Like PD Sheehan likes this
TAGS
AUG Leaders

Atlassian Community Events