How can I conditionally hide a field in Issue Edit screen in Jira On Perm, like this video shows in Jira Cloud

243 Views Asked by At

What I want

This YouTube video shows how to achieve the behavior I am looking for from Jira Script Runner with Behavior feature.

https://www.youtube.com/watch?v=-Jt9BIlGcq4

Can anyone help me identify the right script for this live update (per YouTub video) if it is possible in the on perm version of Jira with Script Runner - or confirm its only possible on cloud?

What I get

The above video is for Jira Cloud. When I try to activate a script on a field to conditionally hide it based on another drop down field value selection it does not work in server version.

Atlassian Jira Project Management Software (v9.4.3) ScriptRunner for Jira (v8.0.0)

I don't have the same options as the video

  • On Load, and On Change check box don't exist
  • CheckBox options include

"Optional Click to make required" "Writable Click to make readonly" "Shown Click to make hidden"

Conditions available include a choice of

When (Behaviour will happen if condition is true) Except (Behaviour will not happen if condition is true) With a selection that does not fit including user and workflow related choices. So I choose no condition.

When I choose "Add server-side script" option I can't refer to the same values as in the typed example.

  • const is not a valid keyword.

I get the error "Unexpected input; 'const'"

  • field.getValue().name -> .Name is not a valid property

I get the error "[Static type checking] - No such property: name for class: java.lang.Object"

What I have tried:

I was able to follow another guide and get the field to hide and show by selection of the field I want. However this method only updates the visibility of the secondary impacted field after the user saves the first selection and completely re-loads the issue as another edit. I am looking for a live update though before saving the record.

I was able to get the 1/2 desirable behavior to work using this script: But it only updates after you save and reload the record.

import com.onresolve.jira.groovy.user.FormField

FormField drivingField = getFieldById('customfield_11111')
FormField impactedField = getFieldById('customfield_22222')

impactedField.setHidden(true)

def drivingFieldValue = drivingField.getFormValue();

if (drivingFieldValue =="12345" || drivingFieldValue =="98765") // Hidden for No, and N/A
{
    impactedField.setHidden(true)
}
else {
    impactedField.setHidden(false)
}

Seeking the dynamic re-load, I have tried several articles including the below Adaptavist documentation: https://docs.adaptavist.com/sr4js/latest/features/behaviours https://docs.adaptavist.com/sr4js/search?q=scheme&max=10&s=AD4C&s=AB&s=CF4CC&s=CF4CS&s=CFM4CC&s=CFM4CS&s=E4J&s=ES&s=ET&s=F4CC&s=F4CS&s=H4JC&s=JSU4JC&s=KCL&s=KCRM&s=L4J&s=LFJAT&s=MICRO&s=1SP&s=R4C&s=SR4BAM&s=SR4BIB&s=SFB&s=SR4CC&s=SFC&s=SR4C&s=SR4JC&s=SFJCL&s=SFJ&s=SR4JS&s=SEARCHMY&s=TB4C&s=TFO4J&s=WS4J&start=10

This other behavior for example works great: https://docs.adaptavist.com/sr4js/latest/features/behaviours/behaviours-examples/restricting-priority-and-resolution

Jira documentation: https://confluence.atlassian.com/adminjiraserver/specifying-field-behavior-938847255.html?_ga=2.221246619.2032839952.1696598808-199564665.1695831347 https://community.atlassian.com/t5/App-Central-questions/Can-t-hide-fields-on-view-screen-using-behaviours/qaq-p/721299 https://community.atlassian.com/t5/App-Central-questions/Show-hide-custom-field-using-Behaviors-from-Adaptivist/qaq-p/597146 https://community.atlassian.com/t5/Jira-questions/Show-or-Hide-the-custom-field-based-on-the-radio-button-option/qaq-p/2115218 https://community.atlassian.com/t5/Jira-Software-questions/Hide-fields-on-the-create-screen/qaq-p/1388731 https://community.atlassian.com/t5/Jira-questions/Jira-script-listener-behavior-how-to-control-hiding-unhiding-a/qaq-p/1762109 https://community.atlassian.com/t5/Jira-questions/Scriptrunner-behavior-to-hide-show-field-based-on-value-of/qaq-p/2242414?lightbox-message-images-2242473=234905iF9A939FF71537F33

Past Stack overflow question: JIRA Hide fields in View

YouTube above: https://www.youtube.com/watch?v=-Jt9BIlGcq4

  • other numerous YouTubes I didn't keep track of as they didn't work.

Final Plea

Can anyone help me identify the right script for this live update (per YouTub video) if it is possible in the on perm version of Jira with Script Runner - or confirm it's only possible on cloud?

0

There are 0 best solutions below