Forums

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

Hide custom fields based on drop down selection

Garden16_
March 25, 2022

I have a custom field that  displays User story   and Epic  (Issue type 1 and Issue type 2)

This custom field is multi issue search picker. I have created this field using the scripted field in Script runner.

I have custom Field A, Field B and Field C which have to be displayed based on the issue type selected in the drop down custom field  - User story and Epic(Issue type 1 and Issue type 2) 

If issue type 1 (user story) is selected from the drop down then the other custom fields A,B , C have to be displayed . If I select Issue type 2 (epic) the custom fields A,B , C should not be displayed .

 

How do I achieve it using script runner behavior code 

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Nicolas PR
Contributor
August 9, 2022

Hi there,

I did something similar with scriptrunner, but i didn't find how to specially trigger a kb_search with a value.

Instead, I catch the value of a customfield (my need here) and inject it in the summary field value and then trigger the search action through 'jQuery(\"#summary\").trigger(\"paste\");' who's calling the search. I did it by injecting js in summary.helpText

/* Behaviour for composant field */
def composant=getFieldById(getFieldChanged())
def composantVal=composant.getValue()

// SUMMARY EDiT
def summary=getFieldById("summary")
def summaryVal=summary.getValue() as String

if (composantVal!=null) {
    summary.setFormValue((String)composantVal)
    summary.setHelpText("<script>jQuery(\"#summary\").val(\""+(String)composantVal+"\"); jQuery(\"#summary\").trigger(\"paste\");</script>")
} else {
    summary.setHelpText("<script>jQuery(\"#summary\").val(\"\"); jQuery(\"#summary\").trigger(\"paste\");</script>")
}
0 votes
Nicolas PR
Contributor
October 6, 2020

Hi Laurens,

I just finished to implement the behavior to fill summary field but i'm now facing the exact same issue than you ... trigger the kb search..

A solution would be to add js script but i can't find any documentation on the topic ... (change the js listenner on the field)

Did you found any solution ?

TAGS
AUG Leaders

Atlassian Community Events