Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Hide issuePicker custom field drop-down when Epic link is present

Alok Juneja
Contributor
September 1, 2023

Hi,

 

Jira version: v9.5.0

Using scriptrunner

I have a issue type "Feature"

I have created a issuePicker custom field called "Feature link", that I want to hide when "Epic Link" is present in Story. The motivation here is that a story can either be connected to Epic or to Feature and not both.

In the issue edit mode, when I enter the epic link, the "parent link" drop-down option of "parent link" disappears instantly however field name and help text is remaining. In case of custom field "feature link", the drop down menu is still visible.

Capture99.PNG

 

The behavior script on Field "Feature Link" that I am using 


import com.atlassian.jira.issue.IssueFieldConstants
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript


@BaseScript FieldBehaviours fieldBehaviours

def epicField = getFieldByName("Epic Link")
def featureField = getFieldByName("Feature Link")

if (epicField.value) {
  featureField.setReadOnly(true)
  featureField.setHelpText("Cannot use Feature Link when Epic link is set.")
}
else if (!epicField.value) {
  featureField.setReadOnly(false)
  featureField.setHelpText("")
}


 

Any suggestions about that how to make the "Feature Link" drop-down to dis-appear.

 

Another question in continuation to it:-
Once "Feature Link" custom field has Jira number and later I put the Epic Link, eventhough the "Feature Link" field is readonly but has Jira number. Is there any way to reset the field value to placeholder text "Select Feature"

 

Br.

Alok

2 answers

1 accepted

1 vote
Answer accepted
Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 1, 2023

You're likely looking to use `FormField#setHidden(true)` which should remove the field from the form completely (well, not remove, hide).

 

Once "Feature Link" custom field has Jira number and later I put the Epic Link, eventhough the "Feature Link" field is readonly but has Jira number. Is there any way to reset the field value to placeholder text "Select Feature"

I'd probably try something like

featureField.setFormValue(null)

 

A null should be a valid value no matter the field type as far as I know.

You would though need to pin that behaviour on the 'Epic Link' field - so that the behaviour will execute when the field is updated (i.e., someone setting a value). As normally as a server side behaviour it will just run once the form loads, but to make it trigger on field changes, the script has to be attached to the field.

Alok Juneja
Contributor
September 3, 2023

Hi @Radek Dostál 

Thanks for the tips, they worked. Setting to null solved the issue.

featureField.setFormValue(null)

Attaching to "Epic Link" field was the one I was missing. I was attaching my behavior to "Feature Link" and that was not right.

 

"featureFeild.setHidden(true)" function also hides the helptext, However I want to show it to the user the helptext about why user can not select the feature link. 

I have another question for that I create another discussion and not messing it here.

 

Once again thanks.

Br

Alok

0 votes
Alok Juneja
Contributor
September 3, 2023

.

Suggest an answer

Log in or Sign up to answer