Basic Administration > Supporting Collaboration > Workflow Administration > Workflow Tools > Workflow Template Administration > Workflow Code Samples > Vote Tallies > Voting Example: Three Events
  
Voting Example: Three Events
In this example, there is a team with 10 members. The team is designing new shirts for their team uniform.
The team is voting on which colors to use. They are given three routing events:
Blue
Yellow
Red
Every member is a required participant.
WfTally.any
You can vote for blue, yellow, or red.
Every color that receives one or more votes is included in the new shirt design.
Routing Type
Expression
Votes
Outcome
Manual exclusive
//Get the object that represents this activity.
WfAssignedActivity mySelf = ((WfAssignedActivity)self.getObject());

//Get the routing events for this activity.
Vector userEvents = (Vector)mySelf.getUserEventList();


//Specify the result.
result = WfTally.any(self, userEvents);
Yellow 9
Blue 0
Red 1
Yellow and red
WfTally.all
You can vote for blue, yellow, red, or any combination of each.
If a color receives one vote from every user, it is included in the new shirt design.
If no color receives a vote from every user, then a new shirt is not designed.
Routing Type
Expression
Votes
Outcome
Manual
//Get the object that represents this activity.
WfAssignedActivity mySelf = ((WfAssignedActivity)self.getObject());

//Get the routing events for this activity.
Vector userEvents = (Vector)mySelf.getUserEventList();


//Specify the result.
result = WfTally.all(self, userEvents);
Yellow 8
Blue 3
Red 9
No new shirt
WfTally.all
You can vote for blue, yellow, or red.
If every user votes for blue, then the new shirt is blue.
If every user votes for yellow, then the new shirt is yellow.
If users vote for a combination of colors, then the new shirt is red.
Routing Type
Expression
Votes
Outcome
Manual exclusive
//Get the object that represents this activity.
WfAssignedActivity mySelf = ((WfAssignedActivity)self.getObject());

//Specify the result.
result = WfTally.all(self, "Blue", "Red");
if (result != "Blue")
{
result = WfTally.all(self, "Yellow", "Red");
}
Yellow 8
Blue 2
Red 0
Red
WfTally.percent
You can vote for blue, yellow, red, or any combination of each.
The shirt includes every color that receives a vote from more than 30% of the users.
For information on operators, see Tallying Operator.
Routing Type
Expression
Votes
Outcome
Manual
//Get the object that represents this activity.
WfAssignedActivity mySelf = ((WfAssignedActivity)self.getObject());

//Get the routing events for this activity.
Vector userEvents = (Vector)mySelf.getUserEventList();


//Specify the result.
result = WfTally.percent(self, WfTally.GT, 30, userEvents);
Yellow 7
Blue 4
Red 2
Yellow and blue
WfTally.number
You can vote for blue, yellow, red, or any combination of each.
If 3 or more people vote for a color, then the color is included in the new shirt design.
For information on operators, see Tallying Operator.
Routing Type
Expression
Votes
Outcome
Manual
//Get the object that represents this activity.
WfAssignedActivity mySelf = ((WfAssignedActivity)self.getObject());

//Get the routing events for this activity.
Vector userEvents = (Vector)mySelf.getUserEventList();


//Specify the result.
result = WfTally.number(self, WfTally.GTE, 3, userEvents);
Yellow 2
Blue 9
Red 3
Blue and red
WfTally.plurality
You can vote for blue, yellow, or red.
The shirt is the color that receives the most votes.
If there is a tie for most votes, the shirt includes each color in the tie.
Routing Type
Expression
Votes
Outcome
Manual exclusive
//Get the object that represents this activity.
WfAssignedActivity mySelf = ((WfAssignedActivity)self.getObject());

//Get the routing events for this activity.
Vector userEvents = (Vector)mySelf.getUserEventList();


//Specify the result.
result = WfTally.plurality(self, userEvents);
Yellow 2
Blue 4
Red 4
Blue and red
WfTally.notPlurality
You can vote for blue, yellow, or red.
The shirt is the color that receives the fewest votes.
If there is a tie for most votes, the shirt includes each color in the tie.
Routing Type
Expression
Votes
Outcome
Manual exclusive
//Get the object that represents this activity.
WfAssignedActivity mySelf = ((WfAssignedActivity)self.getObject());

//Get the routing events for this activity.
Vector userEvents = (Vector)mySelf.getUserEventList();


//Specify the result.
result = WfTally.notPlurality(self, userEvents);
Yellow 2
Blue 4
Red 4
Yellow
Related Topics