2

I am creating a list for an upcoming office party and want to restrict the number of people that choose to bring certain items.

Column Names:
Apple Juice (3 people) Orange Juice (3 people) Bottles of water (2 people)

Is there a way to validate or use a calculated column so that when two people choose to bring water or one person chooses to bring two cases of water, the column will not allow any more entries?

1

It is not difficult if you understand some JavaScript, and think of SharePoint WebParts displayed as being data themselves.

  • The trick is to put a hidden View on your New/Edit Form that displays the existing Entries.

  • You can then use that information/data (in the ctx Object or by reading the DOM) to apply any JavaScript you want to your Form (CEWP if you are on SP2010/2013/2016/Online , or use JSLink if you are on SP2013)

I have written multiple SharePoint.StackOverflow answers:

  • Will this allow me to limit the amount of entries for each column? The number needed is different depending on the item. – Flat Banana Nov 3 '16 at 12:40
  • You have to add JavaScript and with that you can manipulate your Form anyway you want. It will not prevent WorkFlows or other code from adding new entries. In you usecase with 3 columns you needs 3 hidden Views on the FormPage so SharePoint counts the number of Items for you.If you are not comfortable with the scripting from the first example, then this method is not for you, or you need to learn some more scripting – Danny '365CSI' Engelman Nov 3 '16 at 15:16
  • Thanks, with the information I originally provided as an example there is a total of over 20 columns. For the amount of scripting that has to go into this miniscule task, I will just a descriptive text to each item and a counter below the column. Thanks for the answer though. – Flat Banana Nov 3 '16 at 15:27
  • With more columns you can change the approach, display a hidden View with all entries. Add a CEWP below that View, use the ctx Object or parse the DOM to get all entries. It does require some scripting, about an hour for people with Client Side Rendering/SharePoint scripting – Danny '365CSI' Engelman Nov 3 '16 at 15:29
0

This is a tricky problem, similar to room reservation.

No way to use a calculated column, as it can only access information within the current item. Same issue with column validation.

0

There is no OOTB way for your requirement. Workaround can be :

Create person or group field for individual items like " Apple Juice 1", "Apple Juice 2", "Apple Juice 3" and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.