Skip to main content
Example scripts
arrow icon
To homepage
Confluence
Data centre icon
Data Center

Create a Task for Each Page Reviewer

Features
Listeners
Created 1 year ago, Updated 1 month(s) ago
App in script
ScriptRunner For Confluence
ScriptRunner For Confluence
by Adaptavist
Compatibility
compatibility bullet
Confluence (6.6 - 6.15)
compatibility bullet
ScriptRunner For Confluence (5.6.14)
Language |
groovy
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
        )
    }
}
Having an issue with this script?
Report it here