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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.