I need to send a notification via slack when a comment is created for an issue.
I was able to send a message using Scriptrunner Listener "Post a message to Slack".
However, I can't send comment that has been created as part of the message.
My Code is:
<% out << currentUser?.displayName %> comentó en el ticket
This works fine, but when I added the next code:
<% if (lastComment)
out << lastComment
I got an error. Log shows:
groovy.lang.MissingPropertyException: No such property: lastComment for class: groovy.lang.Binding
2020-05-23 01:47:23,924 http-nio-8091-exec-17 ERROR oscar.diaz 107x2234272x1 2etzel 184.108.40.206,127.0.0.1 /rest/api/2/issue/CRO-145/comment [c.o.scriptrunner.runner.AbstractScriptListener] Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, script: com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.PostMessageToChatService
2020-05-23 01:47:23,924 http-nio-8091-exec-17 ERROR oscar.diaz 107x2234272x1 2etzel 220.127.116.11,127.0.0.1 /rest/api/2/issue/CRO-145/comment [c.o.scriptrunner.runner.AbstractScriptListener]
I also have tried with:
<% if (mostRecentComment)
out << mostRecentComment
But get the same error, the only difference is this part:
groovy.lang.MissingPropertyException: No such property: mostRecentComment for class: groovy.lang.Binding
I spent the last 24 hours trying to figure out how send comment via slack when a comment is created for an issue. Something that seems to be so basic, but I can't make it to work.
Please, your kindly help.
Thanks in advance,
The Binding is the context that includes all the variables defined for the script.
Adaptavists makes sure some commonly used variable are available. That's how you're able to just use "currentUser".
But there is no such thing in this binding as lastComment or mostRecentComment
But if you are listening for the Issue Commented event, the event variable includes the comment that raised the event.
So you could do something like this (with some additional formatting suggestions and binding manipulation to do more advanced scripting in the condition block and pass the new variable to the template:
Hi Jira Service Desk community, Atlassian is on a mission to unleash the potential of all teams, and we know that tools are just one piece of that puzzle. With Jira Service Desk, we have productiv...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events