I have a sync setup between ServiceNow and Jira Cloud. I use scripting and have checks to make sure the issue is still open in the incoming jira script. Is there a way to abort the sync if the ticket is closed. If the ticket is closed I skip all remaining tasks. However, the update still tries to happen and I get an error because the Jira ticket can no longer be updated. In particular it seems to error out on the labels field.
Hi and welcome to the Exalate Community!
Thanks for sharing your question or insight, we appreciate your contribution.
A member of the Exalate team or community will review this post and respond as soon as possible.
In the meantime, feel free to explore related topics or join other conversations. We’re glad to have you here!
Hey @apaeth
There are multiple ways to achieve this. Before that can you please confirm what is your source side and target side ? like the sync is from ServiceNow to Jira causing the issue or other way?
Thanks,
Sonal
sync from Service Now to Jira
If you are sure it is giving error for labels then somewhere the labels are being calculated.
To avoid this you can try to add this script:
// there should be some way to find the whether the issue is closed or not but here i can provide you example which you can change
def isOpen = false
if(issue.status.value != “Done”) {
isOpen = true }
if(!isOpen){
issue.labels=issueBeforeScript.labels
}
Thanks,
Sonal
Hi @apaeth !
I have worked on this matter and this what you can do is
if(issue.status.name == 'your close status name here, for example "Done","Closed","Resolved"'){
return new scala.Tuple2(issueKey, scala.collection.JavaConverters.asScalaBuffer(traces).toSeq())
}else{
issue.status = replica.status
}
this return will work to stop the sync when the status of the ticket that is been tried is already closed.
We use only issue.status, as you want to have the ticket first to be moved to the close status, that’s why I didn’t use replica, unless, you want to have the ticket to never be moved to resolved and only if source (Snow), Is already closed, to not update you can use, replica.status.name
BR
Tomas