Hi,
Trying to retrieve the value of the parent issue in a subtask to return a true or false value based on a string containing a fixed issue name of the parent..
How can I retrieve the value of the parent issue. so I can compare it with a fixed string?
Thanks.
Community moderators have prevented the ability to post new answers.
You can test it directly using the Script console by doing something like:
import com.atlassian.jira.issue.Issue import groovy.transform.BaseScript import com.onresolve.scriptrunner.runner.customisers.ContextBaseScript @BaseScript ContextBaseScript script Issue issue = getIssueOrDefault("ABC-1") issue.getParentObject()?.getKey()
"ABC-1" is your subtask
That obviously works using the console, in the other cases you just need the last line as Michel suggested so
issue.getParentObject()?.getKey()
Hi, I understand this is getting the key but if I want the issue name, how would that work out? thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What do you mean by issue name, the summary? Could you give me an example?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try the code above and put at the end: issue.getParentObject()?.metaClass.methods*.name.sort().unique() That will print all the methods you can access to from your issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you have the subtask object then you can just call
subtask.getParentObject()?.getKey()
to get the parent issue objects key.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Testing this in a script field I get the error javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: subtask for class: Script17 A stacktrace has been logged.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok then just use issue instead of the subtask. Issue is always the current issue object you are viewing or editing.
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.