Hi ,
I am trying to create a script listener to get around this : Internal Comments not notifying Agents - https://jira.atlassian.com/browse/JSDSERVER-2418
The reason we need this is that we have a team that is on the road most of the day and they would like to keep a track of what happens on their tickets via mail.
I have got the first part of the script working where emails are sent to Agents but I need to only fire off the event if the last comment is Internal
import com.atlassian.jira.component.ComponentAccessor
def groupManager = ComponentAccessor.getGroupManager()
groupManager.isUserInGroup(issue.reporter, 'jira-servicedesk-users')
Thanks in advance
Yas
hi Joshua Yamdogo @ Adaptavist ,
Nice script for internal comments, many thanks. How can we change this script to Reporter?
import com.atlassian.jira.bc.issue.comment.property.CommentPropertyService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.comments.Comment
import groovy.json.JsonSlurper
final SD_PUBLIC_COMMENT = "sd.public.comment"
def event = event as IssueEvent
def user = event.getUser()
def comment = event.getComment()
def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)
def isInternal = { Comment c ->
def commentProperty = commentPropertyService.getProperty(user, c.id, SD_PUBLIC_COMMENT)
.getEntityProperty().getOrNull()
if (commentProperty) {
def props = new JsonSlurper().parseText(commentProperty.getValue())
props['internal'].toBoolean()
}
else {
null
}
}
if (comment) {
log.debug(comment)
return isInternal(comment)
}
return false
What do you mean by "change to Reporter"? What you are expecting to be done by script? Maybe I can help, but have no idea what you are asking for.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am creating a clone of the record opened by the customer via the service desk into a different project.
If the customer comments on the clone I created, I want to send a warning e-mail to the assigned person via scriptrunner.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys.
I ran into similar problem with one of my customer. Basically we got this problem https://jira.atlassian.com/browse/JSDSERVER-3410 and we are trying to prepare few PoC how to solve it.
One of them is disabled notification scheme + custom listener, which will trigger a notifications for:
And also will be capable to:
We were able to implement above mentioned code, but struggling with last point. Anyone could help with listener? Will give you credential recognition in article I will publish afterward. :-D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Joshua Yamdogo @ Adaptavist
Great this script works well for me. But one question: is there a way to ignore a comment when it has a pasted image?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yaseen,
We have an example in our documentation about checking to see if a comment is internal or not. Could you take a look at it and see if it is of any help?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Joshua ,
Thank you so much for this, Its the right road.
Unfortunately, i am getting this error:
Cannot invoke method getBindings() on null object.
I cant seem to attach the full error but I have provided a screen grab
Thank you so much again.
Yas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Could you post the exact script you are using in your listener?
Let me see if I understand your use-case:
Problem: Internal comments do not notify agents
Solution:
Does that sound correct?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Joshua,
Absolutely correct -
I am using this script :
import com.atlassian.jira.bc.issue.comment.property.CommentPropertyService
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.comments.Comment
import groovy.json.JsonSlurper
final SD_PUBLIC_COMMENT = "sd.public.comment"
def event = event as IssueEvent
def user = event.getUser()
def comment = event.getComment()
def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)
def isInternal = { Comment c -> def commentProperty = commentPropertyService.getProperty(user, c.id, SD_PUBLIC_COMMENT) .getEntityProperty().getOrNull()
if (commentProperty) {
def props = new JsonSlurper().parseText(commentProperty.getValue())
(props['internal'] as String).toBoolean() }
else { null }
}
if (comment) {
return isInternal(comment) }
return false
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have tested the script and it works for me with 100% success. It looks like you have some formatting issues in that script you posted. Is that how the script shows up in your inline script editor? For instance, you have two import statements on the same line in that script.
Could you perhaps try copying and pasting this script and replacing the script you were using?
import com.atlassian.jira.bc.issue.comment.property.CommentPropertyService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.comments.Comment
import groovy.json.JsonSlurper
final SD_PUBLIC_COMMENT = "sd.public.comment"
def event = event as IssueEvent
def user = event.getUser()
def comment = event.getComment()
def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)
def isInternal = { Comment c ->
def commentProperty = commentPropertyService.getProperty(user, c.id, SD_PUBLIC_COMMENT)
.getEntityProperty().getOrNull()
if (commentProperty) {
def props = new JsonSlurper().parseText(commentProperty.getValue())
props['internal'].toBoolean()
}
else {
null
}
}
if (comment) {
log.debug(comment)
return isInternal(comment)
}
return false
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Joshua,
Its all one script , It was just split for some reason in the post.
I am quite sure I am doing something wrong , I have attached a .gif of the steps I take to get there.
I cant thank you enough for helping out here.
Regards
Yas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yas,
After setting up a script listener that sends a custom email, I was able to reproduce this issue. I can see that you will get the "unable to invoke method getBindings()" error.
I think that the error you're receiving has to soley do with the "Preview Issue Key" functionality, not the script itself. I can't quite remember what the issue is with "Preview Issue Key", but I know that it does not work under certain circumstances.
Instead of trying to preview an issue, I would just try to test it on an actual issue. Make an internal comment and see if the listener works. You might edit the listener temporarily to send the email to your address only, so your agents don't get any test emails.
I have tested this script with my own mail server and can see that it does work:
I also see in your picture that you have changed the script to:
(props['internal'] as String).toBoolean()
I would not bother doing that. It's a waste of processing power to do that casting.
This will give you a static type checking error in the inline editor, but the script will still work.
props['internal'].toBoolean()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks so much Joshua, I will test this over the weekend.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Joshua,
The code worked perfectly.
Thank you so much, you have been really awesome helping to get this done.
Kind Regards
Yaya
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.