0

We have SP2013 (PREM). I have a custom list with a date-picker column and another column called "Timeslot" which is a dropdown menu of about 15 20-minute choices. The desired end state is to be able to have this form (newform) present an "error statement" such as "Please choose another timeslot" (much like a validation does) if the user selects the same exact timeslot on the same exact date as another person did so we don't have any "double booking" of these timeslots. Is this achievable OOTB SharePoint or do we need to bring in jquery? Note this is not a calendar webpart but a custom list.

0

I don't think you will be able to do this OOTB without Javascript/JQuery (and I'd recommend SPServices.js).

If your Timeslot column were a standard SharePoint "Date and Time" column, you could set "Enforce unique values" to Yes, and if someone picks the same date/time of a list item that already has that value in that column, it will display "This value already exists in the list".

However, in this case, you would still need some Javascript on your page to change the minute portion of the Date and Time field because the minute drop down has increments of 5 minutes instead of 20. You may also need to use Column Validation to enforce hour or weekday limits.

This method would not work for what I understand you currently have because it sounds like you have the Date and the Timeslot in two separate columns (correct?) You can't use the OOTB "Enforce unique values" on multiple columns.

The Javascript to do this would be simpler than doing the validation by checking the list for previously used values, though that would not be incredibly complex using SPServices and a CAML query.

Another, more messy OOTB way I can think of would be to create another list with all potential timeslots out into some point in the future (perhaps with a Powershell script) and make your Timeslot column a Lookup into that list. Then put a workflow on the main list that either deletes the Timeslot from the lookup list when it is taken, or sets a flag on it to say it is used. For the latter method, you would create a calculated column in the lookup list that returned blank when the timeslot was used, and use that calculated column in your Lookup. Blank values get filtered out for lookups.

But this could potentially have a very long list of lookup values in the drop down list if you go very far into the future.... so then you are back to putting Javascript on the page to filter the lookup list and you aren't OOTB now...

Sorry if this is rambling...

  • @mannagia Thank you for your detailed explaining. I tried with JQuery but it is not working. This is the how it looks: ![enter image description here](i.stack.imgur.com/Odt3M.png) Code I tried: <script type="text/javascript"> $(document).ready(function(){ //Show/hide columns based on Drop Down Selection $("select[title='Time Slot Required Field']").change(function() { if ($("select[title='Project Type']").val() != "Other") { $('nobr:contains("Project Subtype")').closest('tr').hide(); } else { $('nobr:contains("Project Subtype")').closest('tr').sho – sangasangasanga Jul 10 at 7:20

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.