cancel
Showing results for 
Search instead for 
Did you mean: 

Start Workflow and java code

pat9rv3sousa
Champ on-the-rise
Champ on-the-rise
I'm trying to create a workflow that have multiple assignees (done) and launch to them, a task. When I start the workflow, I want to run a java code that makes modifications on file that the task has been assigned. How can I run this java code on "Start Workflow"?

And then, I want that each assignee have a task to approve (this moment, the assignees don't have task to approve, appear task done, how can I do that?), and to approve I want to run other java code. How can I make this ? Assign this java codes to workflow?

I don't know how to define bpmn too, I think some problems are because of this.
2 REPLIES 2

jpotts
World-Class Innovator
World-Class Innovator
In the <a href="http://ecmarchitect.com/alfresco-developer-series-tutorials/workflow/tutorial/tutorial.html#implemen...">workflow tutorial</a> there is an ExternalReviewNotification class that shows one way to have Java code in your process get executed. The class implements the TaskListener interface. So one approach would be to have your Java class implement that interface, then add a task listener to each step in your process where you want to call the Java class.

The example from the tutorial calls the ExternalReviewNotification class when the task is created:


<activiti:taskListener event="create" class="com.someco.bpm.ExternalReviewNotification"></activiti:taskListener>


Jeff

Thank you so much Jeff!
I edit this reply because I already solve what I answer you before.

Now I have a question, in this java file, I want to access the assignees the I have on the task that I'm starting. When I click Start Workflow (to make the task) I access the java. There are one way to access the assignees in the java in this time?


PS: in your bpmn that you have one task user and one script, this script is the listener or the external notification? I'm trying to understand why to put this script on bpmn. I Thanked very especially this last question.