Tally Expression Sample with More than One Tally Call
This topic provides a sample of using more than one tally call in an expression and the prevention of firing the same event twice.
Referenced Workflow
TallyExpressionWithTwoTallyCalls.xml
Description
It is possible to have more than one tally call within the same expression. In this case, there is a risk of adding the same routing event to the list of events more than once. To avoid this, use the setEvents( ) method, as shown in the example. This method collects nonduplicate routing events, so that each routing event in the list is fired only once. The expression below conducts a poll on the number of times "Test" has been chosen and stores the result to a vector tallyResults. It then conducts a poll on the percentage of assignees that chose "Modify," rather than the other two. The result of this poll is now added to the vector tallyResults. The use of the setEvents method prevents the event "Modify" (which appears in both tally calls) from appearing twice in the list of events to fire. The result is then set to the vector tallyResults.
Instructions
There can be any number of routing events for this activity. Only the votes of assignees who have been chosen to be required in the workflow definition are used in the poll.
Copy the following code:
//Create a vector that will hold all the non-duplicated UserEvents chosen for this activity.

Vector tallyResults = new Vector( );

//Get the object representing this activity.
wt.workflow.work.WfAssignedActivity mySelf = (( wt.workflow.work.WfAssignedActivity ) self.getObject( ));

//Get all the UserEvents for this activity. The resulting Vector may hold duplicate values of some events.
Vector userEvents = (Vector) mySelf.getUserEventList( );

//If "Test" receives 2 or more of the required votes, get "Test", else get "Modify".
//Collect the non-duplicated events into the Vector tallyResults ( i.e add only those events that do not already exist in the vector.
WfTally.setEvents(tallyResults , wt.workflow.work.WfTally.number(self , WfTally.GTE, 2, "Test", "Modify"));

//If "Modify" receives more than 35% of the required votes, get "Modify" else get "Approve and Release".
//Collect the non-duplicated events into the Vector tallyResults ( i.e add only those events that do not already exist in the vector.
WfTally.setEvents(tallyResults , wt.workflow.work.WfTally.percent(self , WfTally.GT, 35, "Modify", "Approve and Release"));

//set result to the tallyResults Vector.
result= tallyResults
Isto foi útil?