I'm trying to create a conditional to show/hide a custom field in Jira cloud by Behavior on Script Runner:
Fiels:
- Test in homologation (bolean type)
- Probability (single list type)
Basically:
In the creation screen, if I select "Yes" in the "Test in homologation" field the "Probability" field should appear and if I select "No" the "Probability" field should not appear.
Script:
const testHML = getFieldById('customfield_10388');
const probability = getFieldById('customfield_10415');
const testHMLValue = testHML.getValue().value
switch (testHMLValue) {
case 'Yes':
probability.setVisible(true);
break;
case 'No':
probability.setVisible(false);
break;
}
But when testing, nothing happens, both fields appear and no behavior to hide the probability field is performed.
This is the code I built from the example used in the Script Runner video:
https://www.youtube.com/watch?v=9MNsjBm9New&ab_channel=ScriptRunner
Has anyone also encountered this problem?
Hi @Letícia Deus ,
As done in an example script here, you may have to detect changed fields in your behavior. Assuming, that testHML is a radio button field , this change may work:
const testHML = getFieldById('customfield_10388'); const probability = getFieldById('customfield_10415'); const changedField = getChangeField();
switch (changedField.getName()) {case 'Test in homologation':
switch(changedField.getValue().value) { case 'Yes': probability.setVisible(true); break; case 'No': probability.setVisible(false); break;
}
break; }
Hi Guys,
I just verified that this behavior is not compatible with Jira Service (the way I was trying it).
I reproduced it in a Jira Software project and succeeded!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please clarify what type of field you are using for Test in homologation? Is it also a List or a Radio Button?
I am requesting this so I can test it in my environment and see if it can work.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.