Hi,
I am trying to overwrite issue Due date but the new due date value do not reflect on the issue. Can you please suggest how to over write system fields in JIRA?
if(issuePriority == "Critical"){
issue.setDueDate( new Timestamp((new Date() + 1).time))
}
There is no error logged by log.error() but I still see old due date on the issue after running above code. Please help!
So the srcipt runs correctly, but the date is not updated? Tre reindexing the issue:
issueIndexingService.reIndex(Issue issue).
Also I would try to put log error after if, to see if the condition was met:
if(issuePriority == "Critical"){
log.error("Condition passed")
issue.setDueDate( new Timestamp((new Date() + 1).time))
}
Thanks Damian. Will re-indexing issue each time it is updated, affect the JIRA performance? Will it increase CPU usage?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, its only one Issue and it is reindexed only once, when script fire it up.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tried re-indexing. Log shows updated date but the system due date field still holds the old value:
Here is my script:
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Timestamp
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.util.ImportUtils
IssueManager issueManager = ComponentAccessor.getIssueManager()
IssueIndexingService issueIndexService = ComponentAccessor.getComponent(IssueIndexingService.class);
MutableIssue issue = event.issue as MutableIssue
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
def iPriority = issue.getPriority().name
if(iPriority == "Critical"){
log.error("Condition passed")
issue.setDueDate( new Timestamp((new Date() + 1).time))
}
else if(iPriority == "High"){
log.error("Condition passed")
issue.setDueDate( new Timestamp((new Date() + 4).time))
}
log.warn("Reindex issue ${issue.key} ${issue.id}")
issueIndexingService.reIndex(issueManager.getIssueObject(issue.id));
log.error(issue.getPriority().name)
log.error(issue.getDueDate())
----------------------------------------------------------------
Created an issue with Due date = 9 Dec 2019
Here is the log result:
2019-12-09 14:21:45,677 ERROR [runner.AbstractScriptRunner]: Condition passed 2019-12-09 14:21:45,678 WARN [runner.AbstractScriptRunner]: Reindex issue MKT-10 36901 2019-12-09 14:21:45,747 ERROR [runner.AbstractScriptRunner]: High 2019-12-09 14:21:45,747 ERROR [runner.AbstractScriptRunner]: 2019-12-13 14:21:45.678
But, I still see old due date on the ticket.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.