Valid searchers and their keys in Scriptrunner unit test helper

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

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

344 views 0 1
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you