Create worklog based on date custom field and custom field time

Alex Augusto March 2, 2015

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

 

suporte_runner.PNG

 

Regards!

3 answers

1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 2, 2015

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

1 vote
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 2, 2015

You can utilize JIRA REST API worklog method: https://docs.atlassian.com/jira/REST/latest/#d2e795

0 votes
Alex Augusto March 3, 2015

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,
        issue,
        null,
        issue.reporter.name,
        issue.summary,
        issue.getCustomFieldValue(customField),
        null,
        null,
        1*3600
    )
    worklogManager.create(issue.reporter, worklog, 0L, false)
    issue.timeSpent = issue.timeSpent == null 
        ? 1*3600 
        : issue.timeSpent + 1*3600
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 3, 2015

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

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 3, 2015

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

Suggest an answer

Log in or Sign up to answer