Global variables of multi-instance and callActivity?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2011 12:56 PM

However, activiti

I think it is very important. One of the Scenario I can think of, is to terminate the loop under some result receiving from a sub-process. For example, when an activity inside a subprocess fails, you may want to set a variable to say the loop to terminate immediately (with <completionCondition>)…
[size=150]Solution[/size]:
One possible solution I've already tested successfully, is to pass a list from our main to the sub process (well, you can say, pass by the value of a reference)
[attachment=1]activiti.jpg[/attachment]
<callActivity id="callactivity1" name="Call activity" calledElement="subProcess"> <extensionElements> <activiti:in source="list" target="list"></activiti:in> </extensionElements> <multiInstanceLoopCharacteristics isSequential="true"> <loopDataInputRef>…</loopDataInputRef> <completionCondition>${list.size()!=0}</completionCondition> </multiInstanceLoopCharacteristics></callActivity>
By doing this way, every changes to the list inside the subprocess will be visible to the main process. List is now like a global variable for the main and all sub process of the loop. Also, I can trigger the loop to terminate immediately when, for example, the list is not empty as above.[size=150]Problems:[/size]
But another problem, when you use a userTask inside the subprocess, then whatever changes to the list before the userTask, the list will be empty after that.
[attachment=0]activiti2.jpg[/attachment]
I guess, at the userTask, a transaction is completed and all data are persisted to the database. After that, the list we want to reference to, may be not the same list anymore. The above scenario is for sequential loop. For a parallel loop, it is a little bit different. But I want to discuss about sequential loop first. Any ideas to solve the problems would be helpful.
thank you
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2011 04:06 AM



- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2011 05:31 AM
Your suggestion is to write variable from every sub process to different variables of the main process. It's a good idea,. But sadly, the problem is, the element activiti


<activiti
ut sourceExpression="${"HelloWorld"
}" target="i"></activiti
ut>
i is the variable of the main process. If it works, it doesn't matter how many times i is overwritten, we should have "HelloWorld" in i in the end. But not.So when I looked back in the source code of MultiInstanceActivityBehavior, seems like there are no functions to set variables to its parent process when a sub process "leave"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2011 06:01 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2011 06:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2015 08:40 AM
I want to create parallel tasks dynamically using callActivity and if any one of the tasks is Rejected, I want to complete all the tasks and instance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 10:38 AM
Late reply but might be useful for someone else....
One way of dealing with it would be to write a delegate or script to do the following...
execution below is from the subprocess
superExecutionId = execution.getSuperExecutionId();
runtimeService.setVariable(superExecutionId, someVariableName, someValue);
