I'm trying to add a due date to a ticket in Script Runner via a listener and absolutely none of the documentation has been helpful. This all I have so far:
import java.sql.Timestamp;
def issue = event.getIssue();
def dueDate = new Date(System.currentTimeMillis() + 7*24*60*60*1000);
//issue.dueDate.setDate(new Date(System.currentTimeMillis() + 7*24*60*60*1000))
issue.dueDate.setTime(System.currentTimeMillis() + 7*24*60*60*1000)
The goal is to add a due date that is exactly one week after the ticket was created. Can someone please help?
Edit: Also, is there an online textbook or manual where it's explained how to create a custom field? I'm new at this, and I can't find anything like that yet.
Hi @Sam ,
In your Listener make sure the Event to listen to is Issue Created
Here's the working script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def issueManager = ComponentAccessor.getIssueManager();
def issue = event.getIssue();
issue.setDueDate(new Timestamp((new Date() + 7).time))
def currentUserObj = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issueManager.updateIssue(currentUserObj, issue, EventDispatchOption.ISSUE_UPDATED, false)
Hi Bryan,
Thank you for the quick response! However, when I copy and paste the code into the listener, I get the error "unable to resolve class Timestamp" at the line
issue.setDueDate(new Timestamp((new Date() + 7).time))
Do you know why this might be happening?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If there are errors, just ignore it and let the script run, i just tested it earlier.
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.