Fairly self-explanatory but all the Questions on Community revolve around custom fields and/or calculating Estimates for the same based on Links. I just want to very simply pull the Fix Version of the Linked Issue (based on Link Type) and copy it into this Scripted Field.
Keeps displaying an error though, regardless of whether I choose the Custom or Text templates.
Code and screenshot below.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.comparator.VersionComparator import com.atlassian.jira.project.version.Version def issue = issue as Issue def fixVersionsInIssues = [] as List<Version> def comparator = new VersionComparator() ComponentAccessor.getIssueLinkManager(). getOutwardLinks(issue.id)?. findAll {it.issueLinkType.name == "Base"}?. each {it -> fixVersionsInIssues.addAll(it.destinationObject?.fixVersions) } fixVersionsInIssues?.max(comparator)?.name
Any ideas on this, or any of your team have any ideas? Between this and the Base Status not coming over, I'm getting really frustrated :(
Hi Lacey,
I understand your frustration. I've posted an example for getting the base status along with an explanation on your other question here.
Hopefully that will clarify things for you. You should then be able to adapt this script for the fix versions using the same example.
However if your still having issues just let us know and we'll help.
Thanks,
Adam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is still having issues, as stated on other [question|https://community.atlassian.com/t5/Product-Apps-questions/Scripted-field-return-issue-status-of-linked-issues/qaq-p/607560#M34171].
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The "each" line is not valid code. You need a -> after the it, not a control sequence.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh you are so right about the line in so much that it looks like an ASCII translation in pasting.
Still doesn't solve the issue though, coming up blank still. I'm taking this directly from another Adaptavist code block that line.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.comparator.VersionComparator import com.atlassian.jira.project.version.Version def issue = issue as Issue def fixVersionsInIssues = [] as List<Version> def comparator = new VersionComparator() ComponentAccessor.getIssueLinkManager(). getOutwardLinks(issue.id)?. findAll {it.issueLinkType.name == "Base"}?. each {it -> fixVersionsInIssues.addAll(it.destinationObject?.fixVersions) } fixVersionsInIssues?.max(comparator)?.name
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I think you need a return on last line.
I note it's scanning for many links and just grabbing one of them to give you. I'm not sure what the comparator will return there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From what I understand of the original question and its response, the intent was to get the latest fixVersion, I believe. That doesn't apply to me since I have another script in place for limiting the field to 1 value, but I kept it in there because it can't hurt (I thought).
And I have a return on the other code and that doesn't work either. See my other question about Scripted Fields submitted today.
I put in to return the fixVersionInIssues but no dice. Same blank as before.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I thought I should check, in case you were expecting something else.
My next thought - I don't think it.issueLinkType.name is a valid call, I think it should be it.issueLinkType.getName()
One other thought too - when these scripts chuck errors out, they go into the log, usually with a lot more information (for example, if I'm right about the getName, your code would be throwing something like "unknown property: name" when it hits it). When I'm using a preview to check a scripted field, I tend to be tailing the log alongside it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The log is showing as completely null.
I changed to it.issueLinkType.getName() and the same [] Output and Null in log.
:(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Shouldn't it be:
it.destinationObject.issueTypeObject.name == "Base"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, I am not picking up the issue type, I'm picking up the link type. We don't have an issue type of Base :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nic, do you have any other ideas? The log is null and so is the preview...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That suggests it's not finding any links there. Have you tried logging to see the execution flow?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Everything is null. Logging, output... It's happening for both this as well as my other question, which Daniel has been looking into.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you put a System.out.println("Debug me") line into it somewhere, you are guaranteed a line in the log. Could you try that?
If that doesn't come out, then you've disabled *all* the logging somehow, and your log will only have a bit of startup data in it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Adding just that line to the original code body does nothing.
Doing below throws a generic error. 2017-07-17 16:15:33,851 DEBUG [customfield.GroovyCustomField]: fixVersionsInIssues
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comparator.VersionComparator
import com.atlassian.jira.project.version.Version
import org.apache.log4j.Logger
import org.apache.log4j.Level
def issue = issue as Issue
def fixVersionsInIssues = [] as List<Version>
def comparator = new VersionComparator()
ComponentAccessor.getIssueLinkManager().
getOutwardLinks(issue.id)?.
findAll {it.issueLinkType.getName() == "Base"}?.
each {it -> fixVersionsInIssues.addAll(it.destinationObject.fixVersions) }
fixVersionsInIssues?.max(comparator)?.name
log.setLevel(Level.DEBUG)
log.debug "fixVersionsInIssues"
Now I have this in the Atlassian-JIRA log:
2017-07-17 16:23:43,112 http-bio-443-exec-1311 DEBUG James.Lee 983x1130694x1 u8lgj9 10.255.250.126,10.255.249.199 /secure/AjaxIssueAction!default.jspa [c.o.scriptrunner.customfield.GroovyCustomField] fixVersionsInIssues
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So it can't be getting that far through the script - that line should be in the atlassian-jira.log if it got that far into it.
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.