Hi Community,
I want to show/hide multiple custom fields (text type, checkbox, select list (single/ multiple choices)) based on Select List (single choices) field's values on Issue View screen using Scriptrunner Cloud Behavior in Jira cloud.
Please provide a sample code of "changedField" logic when running On Change and On Load. It will a great help.
Thanks
When using ScriptRunner's Behaviour on Jira Cloud, you need to understand that you cannot code this in Groovy, as the Syntax that is accepted is TypeScript.
For your first requirement of showing/hiding fields, you must do something like this:-
const changedField = getChangeField()
const singleText = getFieldById('customfield_12936')
singleText.setVisible(true)
if (changedField.getName() == 'Single Select List') {
if (changedField.getValue().value == 'Pink') {
singleText.setVisible(false)
}
}
Please note that the sample code above is not 100% exact to your environment. Hence, you must make the required modification.
Firstly, similar to ScriptRunner for Jira DC, since this behaviour depends on the value of a field, you must use the changedField method to initialise the field that will trigger the Behaviour, i.e. getChangeField().
Next, you must add a condition to identify which field has triggered the changed using the first if condition shown in the code above. Unlike in DC, in Cloud, the getChangedField can be used for more than one field.
Also, unlike in Jira Server / DC, you cannot search for a custom field by name. You must search for it using its custom field ID as shown in the example code above.
Below is a screenshot of the Behaviour configuration:-
I suggest going through the Script Runner for Jira Cloud Documentation to understand the concept of the Behaviour.
Below are a few test screenshots:-
1. When the issue dialog first appears for the Create screen all the fields are visible as shown in the screenshot below:-
2. If the Single Select List option is updated to Pink, as expected, the Single Text field is hidden as shown in the screenshot below:-
3. If any other option aside from Pink is selected from the Single Select List, as expected, the Single Text field is visible as shown in the screenshot below:-
I hope this helps answer your question. :)
I am looking forward to your feedback.
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_
As always, thank you so much for your message and solution provided. I'll follow the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Digvijay Singh Gehlot
I think this YouTube video from Adaptavist has what you seek.
https://www.youtube.com/watch?v=9MNsjBm9New
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In Jira Cloud Scriptrunner, Behaviors are limited vs Server/DC you can’t fully hide/show fields, only set them required/optional or read-only; for onChange
you can check the select value and then use setHidden(true/false)
in code, but since it’s not fully supported in Cloud, the workaround is using Forms, Forge apps, or making fields read-only/required instead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
On what are you basing your statement that using the setHidden() option is not fully supported in Cloud?
I'm not seeing any caveats listed for this functionality in the Issue Details View other than a few fields not being supported.
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.