Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation: when issues transitioned to "Done" display "actual end date" with current date. JQL?

Fuji
Contributor
May 4, 2023

Hi Jira Community,

 

I'am want to make an automation so that when an issue is transitioned to "Done" it will automatically set the custom field "actual end date" to current date (not due date or target end date, but the actual date it's moved to "Done"). 

My primary question:

- What is the correct JQL?

Supplemental questions:

- Maybe are other easier ways than JQL?

- Finally, should I start learning basic JIRA JQL? (I'am new in the job as a project coordinator in IT - no coding experience).

 

 

Here is my JQL, that didn't work:

{
"fields": {

"actual end date": {now.dayOfMonth}
}

 

 

Audit log regarding the automation that was tried to implement:

"Action details:
Edit issue
Error while parsing additional fields. Not valid JSON."


Screenshots of 'Custion field "actual end date"' automation:
Webklip_4-5-2023_12645_dbf-it.atlassian.net.jpeg
Webklip_4-5-2023_12624_dbf-it.atlassian.net.jpeg
Best regard
Fuji - project coordinator in IT department (project adminitrator in Jira)

1 answer

2 votes
Gonchik Tsymzhitov
Community Champion
June 18, 2018

Hi! 

 

Let's input worklog first, WorklogInput will help you

https://docs.atlassian.com/jira-rest-java-client-api/2.0.0-m31/jira-rest-java-client-api/apidocs/

 

like this 

public boolean addWorklog(IssueEx issue, String comment) {
try {
URI worklogUri = getIssue(issue.id).getWorklogUri();

WorklogInputBuilder wlBuilder = new WorklogInputBuilder(worklogUri);
wlBuilder.setMinutesSpent(issue.timeSpent);
wlBuilder.setComment(comment);

jiraRestClient.getIssueClient().addWorklog( worklogUri, wlBuilder.build() );
return true;
} catch (Exception e) {
LOGGER.warning( "jira rest client update issue error. cause: " + e.getMessage() );
return false;
}
}

 

Hope it helps 

Cheers,

Gonchik Tsymzhitov

stuck
Contributor
June 18, 2018

Hi, Gonchik. Thanks for your comment.

I tried the code that you gave and I got an error as follows. What should I do?

Exception in thread "Thread-1" java.util.concurrent.RejectedExecutionException: Task com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable@3f10924d rejected from java.util.concurrent.ThreadPoolExecutor@39e30c40[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateExecutor.execute(SettableFuturePromiseHttpPromiseAsyncClient.java:171)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$1.doCancelled(SettableFuturePromiseHttpPromiseAsyncClient.java:68)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalContextAwareFutureCallback$3.run(SettableFuturePromiseHttpPromiseAsyncClient.java:152)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient.runInContext(SettableFuturePromiseHttpPromiseAsyncClient.java:90)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalContextAwareFutureCallback.cancelled(SettableFuturePromiseHttpPromiseAsyncClient.java:147)
at org.apache.http.impl.client.cache.CachingHttpAsyncClient$2.cancelled(CachingHttpAsyncClient.java:636)
at org.apache.http.concurrent.BasicFuture.cancel(BasicFuture.java:135)
at org.apache.http.impl.nio.client.DefaultResultCallback.cancelled(DefaultResultCallback.java:57)
at org.apache.http.impl.nio.client.DefaultAsyncRequestDirector.cancel(DefaultAsyncRequestDirector.java:533)
at org.apache.http.impl.nio.client.AbstractHttpAsyncClient.doExecute(AbstractHttpAsyncClient.java:471)
at org.apache.http.impl.nio.client.AbstractHttpAsyncClient.access$000(AbstractHttpAsyncClient.java:101)
at org.apache.http.impl.nio.client.AbstractHttpAsyncClient$1.run(AbstractHttpAsyncClient.java:485)
stuck
Contributor
June 18, 2018

I claimed it and the problem solved.

Thanks a lot Gonchik! 

stuck
Contributor
June 18, 2018

I can add the worklog like you said Gonchik, thanks.

However, I cannot still resolve the issue. It says "Time Spent is required", again :(

Gonchik Tsymzhitov
Community Champion
June 18, 2018

Okay, have you checked in UI worklog has been added? 

Also can you confirm, is it possible resolve issue from UI? 

Looks like your validator in Jira does not work 

stuck
Contributor
June 18, 2018

Yeap, worklog(s) has added and I can resolve issue from UI.

"Time Spent" fields is required in "Required Close Screen". Because of that I got "Time Spent is required" error.

Also, in UI, if I don't enter any value in "Time Spent" field, I got the same error in UI, too.

Gonchik Tsymzhitov
Community Champion
June 18, 2018

Okay, after addWorkLog method have you seen any changes in UI? 

stuck
Contributor
June 18, 2018

Yes, in issue's page, a work log added after addWorkLog method. For that, additionally I add a ".claim()" at the end of the 

jiraRestClient.getIssueClient().addWorklog( worklogUri, wlBuilder.build() );

line.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events