Xpath constraint for retrieval.

0
Hi, I have users and tasks. A user can have multiple tasks assigned to him. I am trying to implement an auto-assign feature where in with the click of a button all the tasks will be automatically assigned to all the users one by one. So I iterate over the tasks and in the loop I retrieve a single user who does not have any tasks assigned to him. I use the xpath constraint given below to pull the first user object with no tasks assigned. [not(Project.Tasks_Users/Project.Tasks)] Once all users have been assigned a single task I'd like to assign a second task one by one to all users. So in the next activity within the loop I'd like to retrieve users with just one task assigned. What is the xpath constraint I should use to retrive users with only one task assigned to them?
asked
2 answers
2

Retrieve the the users with tasks (remove the not) and then retrieve the tasks followed directly with a count of the tasklist retrieved. Then in a split decide if action is needed.

answered
0

Example:

1) Get count of tasks unassigned (43)
2) Get count of users with no assignment (15)
3) Give each of those users 1 (43 - 15 = 28 left)
4) Get count of all users (25)
5) Iterate through each and use a counter
5a) For each user, assign (total / users) tasks + (total % users > 0 && total % users >= counter ? 1 : 0)
For example, 1st user will get (28 / 25) = 1 + ((28 % 25 = 3) > 0 && 3 >= 1) = 1 ==> 2
2nd user will get 1 + 1 => 2
3rd user will get 1 + 1 =>2
Rest get 1 + 0 => 1

There are other ways but figuring out how many to assign, I believe, is one of the easiest

answered