Valid searchers and their keys in Scriptrunner unit test helper

Thorsten Joergensen June 22, 2017

I would like to do unit tests with easy creation of issues with custom fields with Scriptrunner.

 

I am looking for valid searcherKey arguments in code like:

ScriptFieldCreationInfo.Builder.newBuilder().setSearcherKey("datetimerange")

 

All I can succeed with is the example, and the no argument option.

1 answer

0 votes
Thanos Batagiannis _Adaptavist_
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.
June 26, 2017

Hi Thorsten,

So the available serachers for scirpted fields will be 

.setSearcherKey(ScriptRunnerImpl.PLUGIN_KEY + ":textsearcher")
.setSearcherKey(ScriptRunnerImpl.PLUGIN_KEY + ":datetimerange")
.setSearcherKey(ScriptRunnerImpl.PLUGIN_KEY + ":exacttextsearcher")
.setSearcherKey(ScriptRunnerImpl.PLUGIN_KEY + ":exactnumber")
.setSearcherKey(ScriptRunnerImpl.PLUGIN_KEY + ":numberrange")
.setSearcherKey(ScriptRunnerImpl.PLUGIN_KEY + ":userpickersearcher")
.setSearcherKey(ScriptRunnerImpl.PLUGIN_KEY + ":multiuserpickersearcher")
.setSearcherKey(ScriptRunnerImpl.PLUGIN_KEY + ":durationsearcher")
.setSearcherKey(ScriptRunnerImpl.PLUGIN_KEY + ":versionsearcher")

Therefore an example of creating a scripted field with a textsearcher and a custom template would be 

import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.onresolve.scriptrunner.test.ScriptFieldCreationInfo

def scriptFieldCreation = ScriptFieldCreationInfo.Builder.newBuilder()
    .setName("A scripted field example")
    .setTemplate("custom")
    .setSearcherKey(ScriptRunnerImpl.PLUGIN_KEY + ":textsearcher")
    .setScript('issue.reporter?.emailAddress?.replaceAll(/.*@/, "")')
    .setGlobalContext()
    .setCustomTemplate('''\
    $value - <a target="_blank" href="http://$value">Company domain</a>''')
    .build()

def cf = scriptFieldCreation.create()

Hope that hepls.

Regards, 

Thanos

Thorsten Joergensen July 13, 2017

Yes, thank you

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events