Increase count on a thing

Trying to Accomplish
I have an app where that you’re picking people from a list/roster. Then the people you pick are stored to a “Picks” data set. I want to limit the number of times you can pick a person from the list/roster to two times. Then once you’ve reached that limit of two, the person would no longer show up or be available to pick from the list/roster.
What I’ve tried
I have no idea how to do this. I’ve tried creating a count field and sending the pick from the roster to a data set called picks and adding a 1 to a “number of times picked” field. Where I struggle is increasing that count to 2. ie. it will just create a new row with the same pick and another count of 1.
What I need it to do is search for a previous pick with the same name if it finds that this person has already been picked then increase the count to 2, otherwise create a new entry with a count of 1.

Thanks,
Blake

Hi

If I followed you correctly you may not need the ‘number of time pick field’.

When a user pick a person you can add a condition like ‘do a search in user Picks on this person’:count<2

If the condition is not met the workflow will not run and the person will not be added a third time.

Best

Hey there,

Just to clarify so I can help you, do you want to limit the total number of picks to 2 or limit the amount of times that an individual person can be picked to 2?

Hey @Blake, I have a few approaches for you:

I’m assuming by data set, you mean a data type called Picks, with a field for count and a field for the User (that is picked). If this is the case, I’d structure it like this instead:

Data

  • field (type)

Pick

  • Pick 1 (user)
  • Pick 2 (user)

Then in order to remove the user (if picked twice) from the list/roster, search for users who are in both of those fields for the Pick. I’ll need a little more info on how users are picked to begin with to help you more specifically (is this a search, a dropdown, a repeating group?). Essentially you just want to filter out any user that is in both fields.

Alternatively, if you need to have 1 user per Pick entry, I’d do a similar search with a constraint on the user that created the entries (that is, the user that made the picks). This is to isolate any Picks in your database that are related to the user creating those entries.

@sylvainprivat offered a great suggestion as well: you could add a condition to the users in the roster: if this user is in 2 Picks, disable them from being added.

Feel free to share your editor link or offer a few more details about the elements involved.


Gaby | Coaching Bubble

Thanks for everyone’s help, this is good stuff…

So to clarify my situation. Yes, @blowenthal, I am trying to limit the amount of times that an individual person can be picked to 2.

@romanmg - I think I like your suggestion regarding the structure of Picks. You say I should be able to filter out a person (from the roster/list) that also shows up in the picks twice? That’s what I was wanting to do. But can’t quite get the repeating group to behave as such. That is to say in summary: I have a repeating group that displays a roster/list of people. From this roster a person is “Picked” and their name is sent to the “Pick’s” data. If the name shows in the Picks data twice then they are filtered from the roster. How would you go about doing that?

@sylvainprivat Thanks for your suggestion. I think I follow it, or at least I tried something similar. On the button element that is used to add the person to the Picks data, I put a conditional on the button that searches the Picks data and if the count is greater than 1 (ie 2), the element will not be visible. Thus stopping you from being able to pick the person more than 2 times. (is that what your were describing?) Anyways, the issue with this was that when the page was loading, for a brief moment that button was still active and potentially could have been clicked. I toyed around with loading a shape to block out the entire list while the page loads entirely, but was just hoping to solve it by going after something like @romanmg was suggesting.