Example scripts
To homepage
Confluence

Create a Task for Each Page Reviewer
App in script

ScriptRunner For Confluence
by Adaptavist
Compatibility

Confluence (6.6 - 6.15)

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