Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner what are the import utility classes

Saqib Dar
Contributor
October 26, 2022

Scriptrunner what are the import utility classes we mention the top of scripting and from where i will get it?

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Mahalakshmi Sivasamy
December 27, 2019

Hi All,

 

I am looking code for same scenario like restrcting users to select epic link from different projects.

 

Can you share me the complete code to do this?

0 votes
Ivan Punko
January 22, 2018

Hello @Daniel Tsirlin,

I can't get the whole picture - this validator in postfucntion or Behavior script when you changing some fields (on creating/editing screen)?

as I understand,

epicIssue = issueManager.getIssueObject(epicLinkIssueKey)

will work?

try to add logging to be sure:

logger.debug(epicIssue.getClass())

and don't forget to define your logger.

 

Ivan

Daniel Tsirlin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 22, 2018

Hi Ivan,

Before your message I found out that my code works when I hardcode a string representing epicLinkIssueKey and that my issue is getting that value.

 

Using:

def epicLinkField = getFieldByName("Epic Link")
String epicLinkIssueKey = epicLinkField.getValue().toString()

I get the string equalling to "key:<valueOfIssueKey>"

Using this value for getIssueObject() won't work since there is the "key:" at the front.

scriptrunner is telling me that the output of getValue() is an Object type, so i tried epicLinkIssueKey['key'] (before adding toString()) and it doesn't like it.  I tried making my own map and use the same notation for getting keys and it works, so i assume that the Object isn't what I'm expecting.

 

For now i've decided to make a substring of the output of getValue().toString() to start at index 4, thus it returns just the issue key, however this is quite ugly haha.

 

I don't exactly know how to use the logger you mentioned, but do you know how I could figure out what sort of object you get from getValue()?  The documentation for scriptrunner seems to be poor at best and doesn't help at all.

 

Regards,

Daniel 

Ivan Punko
January 23, 2018

Hi @Daniel Tsirlin,

interesting workaround :)

 

about logging this works for me:

import org.apache.log4j.Logger
import org.apache.log4j.Level

Logger logger = Logger.getLogger("")
logger.setLevel(Level.DEBUG)

logger.debug("Check me in catalina.out")

This should works.

and to get class of object in groovy use:

logger.debug(object.getClass())

 Btw, ScriptRunner has a great tool in admin area, called "Script Consle". You able to see result and logs via UI (but I prefer console with tail -f catalina.out)

TAGS
AUG Leaders

Atlassian Community Events