Create a Task for Each Page Reviewer

Overview

When approvers are assigned to a page, this script automatically creates tasks within Comala Workflows for each reviewer. Edit the script to specify the tasks you wish to assign and set optional due dates.

Example

I have written a proposal and need my team to review it. I would like them to review content, check links, and ensure all diagrams are correct. Instead of creating and assigning these tasks manually, I use the 'Create a Task for Each Reviewer' script to automatically create these three tasks when I add a reviewer.

Good to Know

  • You must have Comala Workflows installed on your Jira instance for this script to work.

Requirements

Confluence Confluence (6.4 - 7.0)

import com.comalatech.workflow.TaskService
import com.comalatech.workflow.event.approval.ApprovalAssignedEvent
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

import java.time.ZonedDateTime

@WithPlugin("com.comalatech.workflow")

def event = event as ApprovalAssignedEvent

// The line below limits this to one space and a workflow state named Review. You can change that to suit your needs
if (event.abstractPage.spaceKey == "MYSPACE" && event.state.name == "Review") {
    def taskService = ScriptRunnerImpl.getOsgiService(TaskService)

    //Get the list of assignees
    def users = event.assignment.assigneesUserNames

    users.each { username ->
        taskService.createTask(
            event.abstractPage,
            "Review task for $username",
            username,
            "Do what you need to do", //Task comment
            Date.from(ZonedDateTime.now().plusDays(7).toInstant()) //Optionally, set a due date for one week hence
        )
    }
}
Discovered an issue? Report it here

Suggested for you