This article explains how to copy work logs from the current issue to the new issue in Create / Clone issue(s) (JMWE app) post-function.
Navigate to the intended workflow to make the necessary changes in the edit mode.
Select the required transition.
Select the Post functions tab and click Add post function
.
Add the “Create / Clone issue(s) (JMWE app)” post-function.
Fill in the required details.
Select the checkbox “Run a Groovy script after the issue is created” under “Post-creation script” and add the below “Post-creation script:”
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.worklog.Worklog import com.atlassian.jira.issue.worklog.WorklogImpl2 import com.atlassian.jira.issue.worklog.WorklogManager List<Worklog> worklogs = ComponentAccessor.worklogManager.getByIssue(issue) worklogs.each { worklog -> Worklog newWorklog = new WorklogImpl2(newIssue, null, worklog.authorKey, worklog.comment, worklog.startDate, worklog.groupLevel, worklog.roleLevelId, worklog.timeSpent, worklog.updateAuthorKey, worklog.created, worklog.updated, worklog.roleLevel) ComponentAccessor.worklogManager.create(currentUser, newWorklog, null, false) newIssue = ComponentAccessor.issueManager.getIssueObject(newIssue.id) } |
With this: A new issue is created with the configured details when the transition is executed and work logs are copied from the current issue.