Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Trigger kb search from scriptrunner

Laurens Coppens Community Leader Jun 20, 2018

We have a scriptrunner script that populates the summary field based on other custom fields, but after populating it, it should trigger the kb search.

When i start typing at the end of summary, it searches, but it doesn't search without human interaction.

Any idea how to trigger the kb search from within scriptrunner?

2 answers

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()

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

if (composantVal!=null) {
    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>")

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 ?

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events