Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Trigger kb search from scriptrunner

Laurens Coppens
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 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

Suggest an answer

Log in or Sign up to answer
0 votes
Nicolas PR 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 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