Hi,
I created a postfunction which is creating some other Issues using the IssueService
class and the validation mechanism.
All created issues shall have the same due date, therefore I added the due date into the IssueInputParameters
and all due dates were set accordingly.
Then I tried to do that with the main issue in which the postfunction is executed. I created the following methods:
private IssueInputParameters createUpdateIssueInputParameters(Issue issue) {
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
String dueDate = getDeadlineString(issue);
log.debug("Updating dueDate to " + dueDate);
issueInputParameters.setDueDate(dueDate);
return issueInputParameters;
}
private Issue updateIssueDueDate(Issue issue) {
log.debug("Updating dueDate for Issue " + issue.getKey());
IssueInputParameters updateIssueParams = createUpdateIssueInputParameters(issue);
ApplicationUser user = jiraAuthenticationContext.getLoggedInUser();
IssueService.UpdateValidationResult updateValidationResult = issueService.validateUpdate(user, issue.getId(), updateIssueParams);
if (updateValidationResult.isValid()) {
log.debug("updateValidationResult dueDate valid");
IssueService.IssueResult updateResult = issueService.update(user, updateValidationResult);
if (updateResult.isValid()) {
log.debug("updateResult dueDate valid");
Issue updatedIssue = updateResult.getIssue();
log.debug("updatedIssue dueDate: " + updatedIssue.getDueDate());
return updatedIssue;
} else {
Util.printErrors(updateResult);
Util.printWarnings(updateResult);
return null;
}
} else {
Util.printErrors(updateValidationResult);
Util.printWarnings(updateValidationResult);
return null;
}
}
The methods Util.printErrors()
and Util.printWarnings()
do what the name says. The method getDeadlineString()
evaluates the deadline date from a cascading select in my main issue, which has to be filled out at the creation of the issue.
After executing my postfunction my logging output of these methods is this (shortened):
Updating dueDate for Issue TEST-71
Updating dueDate to 30/Jun/20
updateValidationResult dueDate valid
updateResult dueDate valid
updatedIssue dueDate: null
The due date is null after the update and in the UI there is no value set. There are no errors or warnings created by the IssueService.validateUpdate()
or IssueService.update()
methods. Why is the due date still null?