Forums

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

Field value null in script runner behavious

Mohammed Monir
Contributor
April 22, 2024

I`m trying to hide field based on custom field in Jira script runner behaviour cloud when selected value is no or null. fields are still showing up when value is null.

 

const triggerField = getFieldById('customfield_11609');

const ticketCategoryField = getFieldById('customfield_11610');

const lineManagerField = getFieldById('customfield_11611');

 

const triggerFieldValue = triggerField.getValue().value

 

    switch (triggerFieldValue) {

      case 'Yes':

        lineManagerField.setVisible(true);

        ticketCategoryField.setVisible(true);

        break;

      case 'No':

        ticketCategoryField.setVisible(false);

        lineManagerField.setVisible(false);

        break;

}

1 answer

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
April 26, 2024

Hi @Mohammed Monir

Could you please clarify what type of fields are: customfield_11609, customfield_11610, and customfield_11611?

I am asking this because ScriptRunner for Jira Cloud is unlike DC. At the moment, only certain types of fields can be used for Behaviour.

I am looking forward to your feedback and clarification.

Thank you and Kind regards,

Ram

Nic Brough -Adaptavist-
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.
April 26, 2024

The reason Ram is asking this is because the comparison may not be valid, depending on the field type.  Some fields may show you "Yes" and "No" on screen, but the actual value (from triggerField.getValue().value ) may not be "Yes" or "No"

Mohammed Monir
Contributor
April 27, 2024

Hello.

triggerField (customfield_11609) is single select list with Yes/No dropdown. If triggered field value is null or No then conditional fields will be hidden and if yes then conditional fields will be visible. I believe this is working now. so when no value selected or No selected, fields are hidden.

 

case ('No' || '!triggerField.getValue()'):
showField0.setVisible(false);
showField0.setRequired(false);
showField1.setVisible(false);
showField1.setRequired(false);
break;

Thank you

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events