I have a workflow which is have an review state, In that state i need to create tasks for all the assigned users as soon as reviewers got assigned to the workflow.
Please suggest.
Hey, Karteek.
ScriptRunner for Confluence can do this. There's a few pieces to put together:
You can create event listeners which listen for Comala events. See the ScriptRunner docs for an example of creating issues in a linked Jira instance based on Comala Workflow events. Comala helpfully document their workflow events, and I think the event you'll want is the ApprovalAssignedEvent. You'll need to check the event properties to make sure your page is in the review state.
import com.atlassian.sal.api.component.ComponentLocator
import com.comalatech.workflow.TaskService
import com.comalatech.workflow.event.approval.ApprovalAssignedEvent
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@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 = ComponentLocator.getComponent(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
new Date() + 7 //Optionally, set a due date for one week hence
)
}
}
Hi Jhonny,
I have created event listener, how you suggested however i gt an error as mentioned below. please suggest.
Error undefined
com/comalatech/workflow/event/approval/ApprovalAssignedEvent
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hm. Is there any more information to the error? A screenshot might help.
Notably, when you configure the listener, you'll need to select the ApprovalAssignedEvent as shown in this screenshot:
What versions of ScriptRunner & Comala Workflows were you using?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please find the exception as below:
java.lang.NoClassDefFoundError: com/comalatech/workflow/event/approval/ApprovalAssignedEvent
at workflow.example.Script334.run(Script334.groovy:16)
at com.onresolve.scriptrunner.runner.AbstractScriptRunner.runScriptAndGetContext(AbstractScriptRunner.groovy:94)
at com.onresolve.scriptrunner.runner.AbstractScriptRunner$runScriptAndGetContext$1.callCurrent(Unknown Source)
at com.onresolve.scriptrunner.runner.AbstractScriptRunner.runStringAsScript(AbstractScriptRunner.groovy:192)
at com.onresolve.scriptrunner.runner.ScriptRunner$runStringAsScript$6.call(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.utils.CustomScriptDelegate.doScript(CustomScriptDelegate.groovy:76)
at com.onresolve.scriptrunner.canned.jira.utils.CustomScriptDelegate$doScript$3.call(Unknown Source)
at com.onresolve.scriptrunner.canned.confluence.events.SimpleScriptedEventHandler.doScript(SimpleScriptedEventHandler.groovy:56)
Caused by: java.lang.ClassNotFoundException: com.comalatech.workflow.event.approval.ApprovalAssignedEvent
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karteek,
It sounds like you want to assign different tasks to different users. I suggest that you consider using Parameters to define the different roles and then you can assign specific tasks to each role.
Take a look at https://wiki.comalatech.com/display/CWL/Parameter+References
Hope that helps, our support team is always available if you have further questions.
James
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, Karteek.
ScriptRunner for Confluence can help you do this.
You can create event listeners which listen for Comala events. See the ScriptRunner docs for an example of creating issues in a linked Jira instance based on Comala Workflow events. Comala helpfully document their workflow events, and I think the event you'll want is the ApprovalAssignedEvent.
Here is some example code that should create one task for every user that was assigned to approve the workflow. Obviously, you'll want to change certain values to fit your use case. I've tried to point those out in code comments, but if you have any questions, let me know!
As always, we recommend that you test your adjusted code in a test instance of Confluence to make sure it does what you want before you push this into production. :)
import com.atlassian.sal.api.component.ComponentLocator
import com.comalatech.workflow.TaskService
import com.comalatech.workflow.event.approval.ApprovalAssignedEvent
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@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 = ComponentLocator.getComponent(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
new Date() + 7 //Optionally, set a due date for one week hence
)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.