Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Introduction

To access the Lookup Manager public API in ScriptRunner, the user need to add these two annotations

  • @WithPlugin(pluginKey) which makes the service class available to the script

  • @PluginModule to inject instance of the module into script

Public APIs

 String getTableList()

Get list of lookup tables

  int getTableIdByName(String tableText)

Get the table id by table name.

  String getTableEntriesById(int lookupTableId)

Get the table entries by tale id.

 ArrayList<String> lookup(int lookupTableId, String srcColText, String srcValue, String destColText)

Execute the lookup and get the matching values provided by the user on input.

Sample code

import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.akelesconsulting.jira.plugins.rest.LookupService
import org.apache.log4j.Logger
import org.apache.log4j.Level
import groovy.json.JsonSlurper

@WithPlugin("com.akelesconsulting.jira.plugins.LookupManager")

@PluginModule
LookupService lookupService

def log = Logger.getLogger("LookupManager")
log.setLevel(Level.DEBUG)
  

log.debug("***** Get table list *****")
def tableListText = lookupService.getTableList()
def tableListArray = new JsonSlurper().parseText( tableListText )
tableListArray.each { log.debug it }

log.debug("***** Get table id by name *****")
int tableId = lookupService.getTableIdByName("Project Category Table")
log.debug("Table id: " + tableId)

log.debug("***** Execute lookup to get matching values *****")
def matchingValuesArray = lookupService.lookup(tableId, "Category", "BUSINESS", "Project Key")
matchingValuesArray.each { log.debug it }

log.debug("***** Get table entries by table id *****")
def tableEntriesText = lookupService.getTableEntriesById(tableId)
def tableEntriesArray = new JsonSlurper().parseText( tableEntriesText )
tableEntriesArray.each { log.debug it }

More Examples

We don't have a way to export this macro.
  • No labels