Can it be that Assignee is empty upon Creation of the issue?
Therefore it has no “previous”?
Because I get the error when it’s a newly created issue, but the script works fine if I enter it and change assignee in an issue that has Assignee set, and I then change it.
So in the case of “Add comment when status is changed”, the script works from start, because the issue always has a status?
So the script needs to be able to send a comment in local when remote Assignee field goes from “Unassigned” to “Marika”.
Thanks!
/Marika
André Leroy-Beaulieu Castro commented on 14 February 2020
if (replica.assignee) {
if (!replica.assignee.equals(previous?.assignee)) {
// construct the comment
String message = “${replica.key}: Assignee updated from ‘${previous?.assignee?.displayName}’ to ‘${replica?.assignee?.displayName}’”
issue.comments = commentHelper.addComment(message, issue.comments)
}
else {
// construct the comment
String message = “${replica.key}: Assignee updated from ‘Unassigned’ to ‘${replica?.assignee?.displayName}’”
issue.comments = commentHelper.addComment(message, issue.comments)
}
}
Would this be sufficient for you? Let me know if this works
Marika Trygg commented on 17 February 2020
Thank you for this extended script! Almost there! (old community)
The last thing I need is for the comments to be synced as External comments from remote Software to local ServiceDesk project. Right now they become Internal comments and does not show in the customer portal.
/Marika
André Leroy-Beaulieu Castro commented on 17 February 2020
Hi Marika,
Can I see some screenshots of your scripts right now? I want to see if there is any outside logic that might be creating these comments as internal…
Thanks,
André
Marika Trygg commented on 17 February 2020
This is how it looks. (Both projects in same Jira instance)
Answer by André Leroy-Beaulieu Castro on 12 February 2020
Hi Marika,
Thanks for raising this question
Outgoing (source side):
replica.assignee = issue.assignee
Incoming (destination side):
if (!replica.assignee.equals(previous?.assignee)) {
// construct the comment
String message = "${replica.key}: Assignee updated from '${previous?.assignee?.displayName}' to '${replica?.assignee?.displayName}'"
issue.comments = commentHelper.addComment(message, issue.comments)
}
This would add the display name of the assignee but you can change that to username or email depending on your needs. Let me know if this works for you!
And also, can the local issue show the name of current assignee without the assignee being a user in the local jira?
you could set this in a text custom field like so: