Hello,
What I am trying to do is simple, and I had a partial success following other posts but not yet completely.
I want to create a ScriptRunner Listener custom script that executes every time an issue is updated, if the issue is associated with a sprint, take its end date and set it as the due date of the issue.
So far I achieved to get the code to set the due date of the issue, but I need to get the sprint end date in "dd/MMM/aa" format to work with this code (according to the documentation of the method here):
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.bc.issue.IssueService
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issue = event.issue
IssueService issueService = ComponentAccessor.getIssueService()
// Get sprint end date
def SprintEndDate = ¿?¿?¿?
// Set Due Date
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setDueDate(SprintEndDate)
def updateValidationResult = issueService.validateUpdate(loggedInUser, issue.id, issueInputParameters)
if (updateValidationResult.isValid()) {
// Validate the update
def issueResult = issueService.update(loggedInUser, updateValidationResult)
}
I also got the part to get the Sprint End Date like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import java.sql.Timestamp;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def sprint = customFieldManager.getCustomFieldObjectByName("Sprint")
//End Date
Date endDate = event.issue.getCustomFieldValue(sprint)?.endDate?.first()?.toDate()
But I am having trouble merging both parts.
Can anyone help me?
Thank you so much in advance.