Field dependency using behaviours

Rahul k May 17, 2019

so i am working on to find a solution to this which is, 

ScField = check boxes

                 A,B,C,D,E,F

TmField - Muliple issue picker

 

and depending on the option i chose, i created subtasks based on the selection of ScField.

 

So, If i choose only "c", the TmField should become optional, if i choose the rest of them along with "c"or without "c" . the TmFIeld should become mandatory.

 

I used this script in behaviours in ScField

 

def ScField = getFieldById(getFieldChanged())

def TmField = getFieldbyId("customfield_11900")

 

def SAC = ScField.getValue() as String

 

TmField.setRequired(!(SAC == "c"))

 

The Problem i am having is even though when TmField becomes mandatory and has a value in it. when i tried to create a issue. it says "Please enter a value in this field".

1 answer

0 votes
Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 17, 2019

Hi @Rahul k ,

This should work. It seems that the behaviours is not updating correctly when you check a checkbox. Have you correctly mapped this script to the ScField in the behaviours configuration ?

Antoine

Rahul k May 17, 2019

yes i did

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 20, 2019

Hi,

Could you please share your exact script and a screenshot of the behaviour configuration ? It would make it easier to debug.

Antoine

Rahul k May 20, 2019

BTD error.PNGBTD Behaviours.PNG

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 21, 2019

Hi @Rahul k ,

I think your screenshot displays an expected result since BTD Epics should only be optional when Infrastructure Change is ticked.

I tested your script and it works fine. However it seems that it triggers when the checkbox is updated, but not at form load. So you might want to add this script in the initialiser, using the id to get sacfield.

Antoine

Suggest an answer

Log in or Sign up to answer