Hello,
I have configured a script which is working in version 2.1.17 on JIRA 6.2.5 and it doesnt work in version 4.2.0.2 on JIRA 7.0.4
I hope someone can give me a hint what have changed in new version and how to fix it.
Thanks!
Kind regards,
Sergey
Script:
<xmp>
<% if (lastComment)
out << lastComment
%>
</xmp>
<xmp>
<br>С уважением,
<br><% out << componentManager.commentManager.getComments(issue)?.last()?.authorUser.displayName %> </xmp>
Error:
groovy.lang.MissingPropertyException: No such property: componentManager for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) at groovy.lang.Binding.getProperty(Binding.java:105) at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:172) at groovy.lang.Closure.getPropertyTryThese(Closure.java:324) at groovy.lang.Closure.getPropertyDelegateFirst(Closure.java:314) at groovy.lang.Closure.getProperty(Closure.java:299) at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:50) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) at groovy.tmp.templates.GStringTemplateScript35$_getTemplate_closure1.doCall(GStringTemplateScript35.groovy:11) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) at groovy.lang.Closure.call(Closure.java:426) at groovy.lang.Closure$WritableClosure.writeTo(Closure.java:856) at groovy.lang.Closure$WritableClosure.toString(Closure.java:982) at sun.reflect.GeneratedMethodAccessor3277.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117) at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$_getDescription_closure15$_closure26$_closure34.doCall(SendCustomEmail.groovy:672) at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$_getDescription_closure15$_closure26$_closure34.doCall(SendCustomEmail.groovy) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) at groovy.lang.Closure.call(Closure.java:426) at groovy.lang.Closure.call(Closure.java:420)
Use ComponentAccessor... there is information on the changes you will need here: https://scriptrunner.adaptavist.com/latest/jira/releases/release-4.1.4.html
You will probably need to use the fully-qualified class name.
Hi Jamie,
I am using Listners to send custom email for commented events, but not able to show comment author and time in email template.
FYI, How to add comment author and time
<b>Assignee :</b> $issue.assignee
<br>
<b>Reporter :</b> $issue.reporter
<br>
<b>Description :</b> $issue.description
<br>
<b>Labels :</b> $issue.labels
<br>
<% if (mostRecentComment)
out << "Last comment: " << mostRecentComment
%>
def commentList = com.atlassian.jira.component.ComponentAccessor.getCommentManager().getComments(issue)
if (commentList)
out << "AUTHOR : " << commentList.last()?.authorUser.displayName
%>
Also please guide on how to add who invoked event, for status or updated or commented events?
Thanks in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sergey,
The getCommentManager was missing, therefore with the changes Jamie proposed the template should be
<xmp> <% if (lastComment) out << lastComment %> </xmp> <xmp> <br>С уважением, <br><% def commentList = com.atlassian.jira.component.ComponentAccessor.getCommentManager().getComments(issue) if (commentList) out << commentList.last()?.authorUser.displayName %> </xmp>
Also you have to check if there are comments because even if you use the '?' operator you will still get a Cannot access last() element from an empty List
Kind regards
Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jamie,
Thank you for you answer, I missed it sorry for that.
I am not sure that understood you well, I changed next:
<% out << componentManager.commentManager.getComments(issue)?.last()?.authorUser.displayName %>
to:
<<% out << com.atlassian.jira.component.ComponentAccessor.getComments(issue)?.last()?.authorUser.displayName %> </xmp>
In this case I got an error:
No signature of method:com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.tr() is applicable for argument types: (com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$_getDescription_closure15$_closure26) values: [com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$_getDescription_closure15$_closure26@14f6db6b] Possible solutions: is(java.lang.Object), any(), grep(), with(groovy.lang.Closure), grep(java.lang.Object), any(groovy.lang.Closure)
Am I on the right way?
Thanks
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.