script runner behaviours-How to select list custom fields behaviour

Cem Tuğrul November 5, 2023

Here is my script but it gives error ;

def Welches System = getFieldById("customfield_25108")
def Welcher Service/Betroffene Kachel = getFieldById("customfield_25203")

if(Welches System.getValue()){
def selectedOption = Welches System.getValue() as String
if(selectedOption == "MKH"){
Welcher Service/Betroffene Kachel.setHidden(true)
Welcher Service/Betroffene Kachel.setRequired(false)
}else{
Welcher Service/Betroffene Kachel.setHidden(false)
Welcher Service/Betroffene Kachel.setRequired(true)
}
}

 

what I am wanting if the customfield_25108 is as a value select "MKH" then my other cascade type customfield_25203 hidden(true) and requied(false)

the other options for my  customfield_25108 ;

"None"

"NKH"

When selected value as "NKH"  then customfield_25203 required(true)

 

1 answer

1 accepted

0 votes
Answer accepted
Murat Seven
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 Leaders.
November 5, 2023

Hi @Cem Tuğrul , thanks for your question.

I've tested the script in a similar manner in my instance and it's working. Are you sure you've added the script to the correct field in the behavior?

For example, as I indicated in the screenshot, since my variable field is "assetCF", I selected it from the field section and added the script to it. Please double-check, and if the issue persists, could you please provide more information?

 

Screen Shot 2023-11-05 at 8.29.03 PM.png

Best,
Murat Seven

Cem Tuğrul November 5, 2023

Hi Murat,

 

I have changed as below then it is working now. (Çok saol Hocam)

 

def WelchesSystem = getFieldById("customfield_25108")
def WelcherServiceBetroffeneKachel = getFieldById("customfield_25203")

if(WelchesSystem.getValue()){
def selectedOption = WelchesSystem.getValue() as String
if(selectedOption == "MKH"){
WelcherServiceBetroffeneKachel.setHidden(true)
WelcherServiceBetroffeneKachel.setRequired(false)
}else{
WelcherServiceBetroffeneKachel.setHidden(false)
WelcherServiceBetroffeneKachel.setRequired(true)
}
}

Like Murat Seven likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events