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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Jul 25, 2018 in Marketplace Apps

Jira Cloud and Bitbucket Cloud Integration with Microsoft Teams

One of the newest products in the Microsoft family - Microsoft Teams,  is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...

717 views 0 3
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