Field value null in script runner behavious

Mohammed Monir 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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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 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