Hello,
I want to delete an issue that it's summary starts with 'XXX' right after it was created.
In the workflow (create transition) I have some other actions , and at the end of the workflow I put a custom script that supposed to delete the issue- it is not working.
I tried to put the same script in script console and it worked.
I tried to create a listener with the same script (issue created event) and it didn't work.
I got this exception:
2020-11-30 08:36:30,832 ERROR [properties.PropertiesUtil]: Exception whilst trying to find value for property 'jira.diagnostics.thresholds.slow-query-millis'. Defaulting to 5000. java.lang.NumberFormatException: For input string: "5000 "
How can I delete this issue ?
This is my script:
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
def issue = ComponentAccessor.getIssueManager().getIssueObject("QAA-760");
//Delete issue if starts with XXX
if(issue.getSummary().toString().startsWith("XXX"))
{
log.warn "inside loop"
log.warn issue.getSummary().toString();
IssueService issueService = ComponentAccessor.getIssueService()
def userManager = ComponentAccessor.getUserManager()
def userDelete = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
log.warn("Delete issue $issue with user $userDelete")
if (issue) {
def validationResult = issueService.validateDelete(userDelete, issue.id)
if (validationResult.errorCollection.hasAnyErrors()) {
log.warn("Can't delete issue")
}
else {
issueService.delete(userDelete, validationResult)
}
}
}
Thank you,
Daniel