Hello everybody. I need to change due date field via REST API but there no any endpoints to set data and time, and I decided to write REST Endpoint via scriptrunner. Here is code
@BaseScript CustomEndpointDelegate delegate
setDueDate(
httpMethod: "POST", groups: ["jira-users"]
) { MultivaluedMap queryParams ->
log.setLevel(Level.INFO)
def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("TEST-767")
def dueDateField = issue.getDueDate()
log.info("Issue Key" + issue.key)
log.info("Old date: " + dueDateField.toString() + " Class: " + dueDateField.getClass().toString())
Timestamp date = new Timestamp(2020, 1, 15, 18, 30, 0, 0)
log.info("Date must be set : " + date)
issue.setDueDate(date)
def newDueDateField = issue.getDueDate()
log.info("New date: " + newDueDateField.toString() + " " + newDueDateField.getClass().toString())
return Response.ok(new JsonBuilder([abc: 42]).toString()).build()
}
When I look at logs everythin is fine and new date is seted
INFO [runner.ScriptRunnerImpl]: Old date: 2019-11-30 18:00:00.0 Class: class java.sql.Timestamp INFO [runner.ScriptRunnerImpl]: Date must be set : 3920-02-15 18:30:00.0 INFO [runner.ScriptRunnerImpl]: New date: 3920-02-15 18:30:00.0 class java.sql.Timestamp
But when I look into issue the old date is seted there
I try in this script add a comment and it works, but date doesn't change :(
ComponentAccessor.getCommentManager().create(issue, issue.getReporterUser(), "bla bla", false)
Will be glad to any help.
There already is a method of setting the due date of an issue, as 'duedate' is a valid field, as per this section of the Jira Server REST API documentation.
The field can be set when the issue is created, or updated afterwards.
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.