Originally asked by Harold Oconitrillo on 27 April 2022 (original question)
Hello,
We have a connection between Jira (on-premise) and Service-Now.
Outgoing code for service-now:
replica.state = entity.state
Incoming Jira code:
// status mapping & status related changes
def statusMapping = ["Closed (resolved)":"Done/Resolved"]
def remoteStatusName = replica.state
if (!replica.state.equals(previous?.state)) {
if (remoteStatusName == "Closed (resolved)") {
statusCommentString = "Current Service-Now state: " + " *" + replica.state + "*" + "\n" + "Previous Service-Now state: " + " *" + previous?.state + "*"
issue.comments = commentHelper.addComment(statusCommentString, issue.comments)
issue.setStatus(statusMapping[remoteStatusName] ?: remoteStatusName)
} else {
statusCommentString = "Current Service-Now state: " + " *" + replica.state + "*" + "\n" + "Previous Service-Now state: " + " *" + previous?.state + "*"
issue.comments = commentHelper.addComment(statusCommentString, issue.comments)
}
}
In Service-Now we have 2 ways of getting to the âClosed (resolved)â state. One transition is called âClosedâ, and the other one is called âReady to Closeâ. After both, the state of the service-now ticket reaches âClosed (resolved)â, the difference beeing some different mandatory fields being filled in before doing the transition, and triggering a checkbox after the action, or not.
When we do the âClosedâ transition in service-now, the Jira ticket gets transitioned to âDone/Resolvedâ.
When we do the âReady to Closeâ transition in service-now, the Jira ticket does NOT get transitioned, although the comment is left as expected with the previous and current status. There are no errors, but it just does not happen.
Please let me know if you need any additional details from our side.
Thank you!
Comments:
Harold Oconitrillo commented on 27 April 2022
Hi,
You may review the documentation below and check the incoming rules.
https://docs.idalko.com/exalate/x/jgF1Aw
Feel free to contact e back if you have any further question.
Thanks.
Serhiy Onyshchenko commented on 01 May 2022
Hey, Harold Oconitrillo , what happens if you remove the mapping from the script:
// status mapping & status related changes
def remoteStatusName = replica.state
if (!replica.state.equals(previous?.state)) {
if (remoteStatusName == "Closed (resolved)") {
statusCommentString = "Current Service-Now state: " + " *" + replica.state + "*" + "\n" + "Previous Service-Now state: " + " *" + previous?.state + "*"
issue.comments = commentHelper.addComment(statusCommentString, issue.comments)
issue.setStatus("Done/Resolved")
} else {
statusCommentString = "Current Service-Now state: " + " *" + replica.state + "*" + "\n" + "Previous Service-Now state: " + " *" + previous?.state + "*"
issue.comments = commentHelper.addComment(statusCommentString, issue.comments)
}
}
Note the
issue.setStatus("Done/Resolved")
part
Regards, Serhiy.
Serhiy Onyshchenko commented on 01 May 2022
And another question: isnât
} else {
statusCommentString = "Current Service-Now state: " + " *" + replica.state + "*" + "\n" + "Previous Service-Now state: " + " *" + previous?.state + "*"
issue.comments = commentHelper.addComment(statusCommentString, issue.comments)
}
supposed to have an
issue.setStatus("...")
?
Regards, Serhiy.
Mihai Arama commented on 02 May 2022
Hi Serhiy Onyshchenko ,
Thank you for your reply!
I removed the status mapping, so the script is now:
def remoteStatusName \= replica.state
def remoteStatusName = replica.state
if (!replica.state.equals(previous?.state)) {
if (remoteStatusName == "Closed (resolved)") {
statusCommentString = "Current Service-Now state: " + " *" + replica.state + "*" + "\n" + "Previous Service-Now state: " + " *" + previous?.state + "*"
issue.comments = commentHelper.addComment(statusCommentString, issue.comments)
issue.setStatus("Done/Resolved")
} else {
statusCommentString = "Current Service-Now state: " + " *" + replica.state + "*" + "\n" + "Previous Service-Now state: " + " *" + previous?.state + "*"
issue.comments = commentHelper.addComment(statusCommentString, issue.comments)
}
}
The same happens, it only works for one transition, but not for the other. The comment still gets added, but the "issue.setStatus(âDone/Resolvedâ) part does not get set.
The second âissue.setStatusâ in the âelseâ clause is not needed, because we only want to change the status of the Jira issue if the service now one is âClosed (resolved)â, not if it is still active or pending other info.
Please let me know if you have any suggestions.
Thank you!
Mihai