Create worklog based on date custom field and custom field time

I have two custom fields:
"Job Data" (Date customfield ID=11811)
"Time Spent" (Number field ID =11812)

I would like that to open a task, be made a worklog based on the date placed in the field and the time placed in the "Time Spent" field

Probably want to put this in the Post Function





3 answers

1 votes
Volodymyr Krupach Community Champion Mar 02, 2015

You can utilize JIRA REST API worklog method:

1 votes

Did you try using WorklogManager to create the worklog? What have you tried so far?

I do not know if I'm doing it right
I do not have developer profile.

What have i tried so far


import com.atlassian.jira.issue.worklog.WorklogImpl
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.MutableIssue
CM = ComponentManager.getInstance()
worklogManager = CM.getWorklogManager()
CustomField customField = customFieldManager.getCustomFieldObject(11811);
   worklog = new WorklogImpl(
    worklogManager.create(issue.reporter, worklog, 0L, false)
    issue.timeSpent = issue.timeSpent == null 
        ? 1*3600 
        : issue.timeSpent + 1*3600
Volodymyr Krupach Community Champion Mar 03, 2015

Looks fine. I see almost the same code in JIRA sources.

I was going to comment pretty much the same. Does it not work?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,848 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot