Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

Instructions

  1. Navigate to the desired workflow transition and add the “Create / Clone issue(s) (JMWE app)” post-function.

  2. Fill in the required details.

  3. Select the checkbox “Run a Groovy script after the issue is created” under “Post-creation script” and add the below “Post-creation script:”

    Code Block
    languagegroovy
    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.

...

References

...