setVisbile Method in Script Runner Behaviour Script Not Working

Adam Holloway October 10, 2024

I have a fairly simple script that sets fields visible on the condition of another radio button field. It is implemented twice, once on issue Create and a second on View or Edit.

 

The one script works on issue Create, as designed. The second script runs on View or Edit but the fields are not hidden. I assume the setVisible Method is either not working properly or is getting overridden by some background Jira process. 

 

 The code between the two scripts is identical in my implementation. The Behaviour logs show the various logger.info statements reached so the script is triggered and runs. All fields that should be hidden are shown though.

Adding a twist, the broken script actually worked for a few days and then just stopped working. Our IT dept said nothing in our Staging Jira has changed. A boiled down version of the script:

 

const strType = getFieldById("customfield_11045")
const theValue = strType.getValue().value;

logger.info(theValue);

//Get Multi-Text Fields
const fldMTextFldDoD = getFieldById("customfield_11029");
const fldMTextFldKG = getFieldById("customfield_10414");
const fldMTextAC = getFieldById ("customfield_10091");


if (theValue == "Something"){
    logger.info("Into IF, at true");
    fldMTextFldKG.setVisible(true);

    logger.info("At false");
    fldMTextFldOutcome.setVisible(false);
    fldMTextFldDoD.setVisible(false);
    fldMTextAC.setVisible(false);
    logger.info("Done");
}
Thoughts?

 

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Adam Holloway November 4, 2024

This was actually a bug between ScriptRunner and Jira cloud confirmed by Adaptavist. This has been resolved with recent App and Cloud updates.

 

0 votes
Kristian Walker _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.
October 14, 2024

Hi Adam,

If you want to make a value visible for a field when a value changes then you need to use the onChange trigger and use the getChangedField() function.

I can confirm that the example script here gives an example of how to make a field visible when a value is selected in a select list field, and you will be able to use this as a reference to help create the script that you require.

Regards,

Kristian

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events