简体   繁体   中英

Groovy (Script Runner/Jira) Get WorkLog from Parent Issue to SubTask

I have a problem with get "Time spent" from Parent Issue to SubTask. Code below could get "Time spent" from WorkLog in Parent Issue to customfield with name "timeLogged", but I need set "Time spent" to Worklog not to customfield. Something like - Copy worklog from Parent Issue to Sub-Task.

def cfManager = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("timeLogged")
//timeLogged - customfield       
def changeHolder = new DefaultIssueChangeHolder()
cfManager.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cfManager), parentIssue.getTimeSpent()),changeHolder)

I found this - https://docs.atlassian.com/jira/7.1.0/com/atlassian/jira/issue/worklog/WorklogManager.html :

.... def worklog2 = new WorklogImpl( worklogManager, subtask, worklog.id, subtask.reporter.name, subtask.summary, new Date(), null, null, summ )
worklogManager.update(subtask.reporter, worklog2, 0L, false) } } ....

And it works !! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM