Preventing Double-booking with Validation

  • 18 December 2017
  • 11 replies
  • 95 views

Badge +1

I'm trying to create a Nintex form in Sharepoint 2013 that helps prohibit double-booking in a Calendar List. To do this I've created a relatively simple formula, using a rule of type "Validation". The formula is 

not(isNullOrEmpty(lookup("ARB Calendar","EventDate",StartTime,"ID")))

When using trying to submit the form I get an on-screen error message that states "Validation Error - There was an issue validating the data entered on the form; please try again. If the problem persists, contact the form owner.". In the browser's debugger I see "Handling all asynchronous validation rules failed". I've been able to validate that the proper data comes back from the server using Fiddler to inspect my web traffic and seeing the JSON response that contains the event that otherwise fulfills the lookup query.

For an interesting twist, I used the same formula for a "Formatting" rule, and that fires just fine turning the label red to help indicate the problem. 

Is there a better way of preventing double-booking of an event in a Nintex form, or perhaps something I'm not doing right here?


11 replies

Userlevel 5
Badge +14

have a look on this post How to connect Forms with JS Function returning an argument 

Is there a better way of preventing double-booking of an event in a Nintex form

in sharepoint you can never reliably avoid double booking (resp. parallel entry of the same information) until you configure a field to 'Enforce unique values'

Badge +1

Thank you Marian, I did look at the post and modified my lookup to try the "length" function, but I get the same results where the validation rule is causing an error to be returned behind the scenes.

not(equals(length(lookup("ARB Calendar","EventDate","EventDate","ID")),0))

or

not(equals(length(lookup("ARB Calendar","EventDate",StartTime,"ID")),0))

There seems to be something happening either deeper in the JS or on the server that is causing this problem. Is there somewhere I should be looking beyond the Console window in Chrome or IE for additional information?

Badge +1

I think I've found a very very janky workaround. Given that calculated fields are pulling back information appropriately, I've moved my logic there, such that it evaluates to "true" or "false". Then in my validation rule I'm checking the calculated control for equivalence to "true" to trigger the validation. This seems to be working so far, though I'd love to solve the core problem rather than use this hack.

Userlevel 5
Badge +14

you miss there one additional parameter in lookup() function call.

try following

not(equals(length(lookup("ARB Calendar","EventDate","EventDate","ID",true)),0))

‌ check item exists‌ double booking‌ double entry‌

Badge +3

This only works for checking that exact date/time, not whether or not the StartDate falls within another events Start/End time.  Did you come up with a solution for that scenario?  Thank you!

Userlevel 5
Badge +14

this is not possible with lookup() function.

it only can make comparison for equality.

Badge +3

Thanks for the information Marian!  Do you know of a way to achieve a true double book check?  I see that the lookup can return back an array of items, is there anyway to leverage that data?

Userlevel 5
Badge +14

Do you know of a way to achieve a true double book check?

sure, I know.

do not use sharepoint happy.png

to be serious, note my above statement

in sharepoint you can never reliably avoid double booking (resp. parallel entry of the same information) until you configure a field to 'Enforce unique values'

you can hardly avoid double booking from client side. definitely not with sharepoint.

it has to be ensured on server/data store side. sharepoint provides an option 'enforce unique values' for a single list field.

if that's not sufficient for you, you are out of luck.

I see that the lookup can return back an array of items, is there anyway to leverage that data?

yes, lookup() function can return array of values. but still just for equality condition (eg. StartTime == <Todat at noon>)

for complex conditions like MyTime falls within date/Time range you would either would need to script it out or check afterwards with workflow.

Badge +3

do not use sharepoint

haha!  I'm beginning to figure that out.  We are currently using the old 2010 group work site feature but I would like to find a solution that can migrate/scale with SP as we upgrade from 2013 and beyond.  Any recommendations?  I was hoping to achieve with Nintex but not looking like I can.

 

it has to be ensured on server/data store side. sharepoint provides an option 'enforce unique values' for a single list field.

I've seen that column on the list but am unsure of its purpose.  Do you know?

We do have Nintex Workflow as well to check after the fact, but the ability to see before an event is created is very much desired by the client.

Userlevel 5
Badge +14

I've seen that column on the list but am unsure of its purpose. 

see reference Enforcing Uniqueness in Column Values 

Badge +11

Hi

Can you share what your form looks like and what field(s) is comparing to?
I have two date fields: StartDate & EndDate and need to compare a List if the dates fall between FromDate - UntilDate

Reply