cancel
Showing results for 
Search instead for 
Did you mean: 
bimi82
Nintex Newbie

Workflow to validate if Date & Time falls within a range and avoid double booking?

Jump to solution

Hello all,

I require help with setting up a workflow process which checks if the selected date & time does not fall within the range of existing date within a custom list in sharepoint 2016 onpremise.

Similarly, I asked somebody to code a JS code to validate on the form:
https://community.nintex.com/message/85369-re-how-to-check-if-a-date-time-falls-within-a-range-and-a... 

can such validation also be performed when the form is submitted via workflow?? Thus is to ensure that the date does not exist in the custom list which may happen if 2 users submit a request within a time at similar time.

Cheers,

Reply
17 Replies
shrinivasnaik
Nintex Newbie

Re: Workflow to validate if Date & Time falls within a range and avoid double booking?

Jump to solution

Hi Bimi,

How do you intend to submit the form "via" the workflow? Any JS you add on the form will only be executed at the client side but workflows wont trigger the JS unless there is a user interaction.

Regards,

Shrini

0 Kudos
Reply
bimi82
Nintex Newbie

Re: Workflow to validate if Date & Time falls within a range and avoid double booking?

Jump to solution

Hi,

In this case it will be only workflow process.
The JS already validates the date/time at the submission process ... but imagine if two users submit same entry at same time, the script would not be able to validate and thefore the workflow would act as a backup.

I found this topic   but I fail to understand it.

0 Kudos
Reply
shrinivasnaik
Nintex Newbie

Re: Workflow to validate if Date & Time falls within a range and avoid double booking?

Jump to solution

Hi Bimi,

The post above "Prevent Double booking" probably does the same check on the WF to prevent double booking. I havent gone into the details of it, but assuming your case would be similar but not exactly same?

In your case I assume if the form is doing the check then you may have to repeat the steps again in the workflow to be sure, but when we do any check in the workflow its a delayed action, i.e the user may not know if his request his successful or not until the workflow does the check and somehow notifies the user (through emails?) whether the booking is successful or not which is not a very ideal User experience.

In your current setup I am assuming you must be checking for the double booking in JS and that should occur at the very end just before the record gets saved into the DB, so if 2 users open at the very same time but 1st user saves it earlier, then when the 2nd user is trying to save it the JS will anyways do a fresh check on the validation and error out? Is this not the case? 

Regards,

Shrini

0 Kudos
Reply
bimi82
Nintex Newbie

Re: Workflow to validate if Date & Time falls within a range and avoid double booking?

Jump to solution

Hello Shrinivas Naik

In regards to the JS validation How to check if a Date & Time falls within a range and avoid double booking? it does validate at the on-change as well as when Submit button is clicked in theory your assumption should work; if user1 submits the request 5 seconds before the user2 .. but this may not be the case due to delays in process etc etc.

Therefore, the Workflow then checks (after the submission has gone) to ensure the dates do not fall in range.

I have implemented the WF suggestion by Darren1372 ( ) and kind of addapted to my needs but I am new to the loops etc and fail to understand the process.

Did you check my email sent to you?

0 Kudos
Reply
shrinivasnaik
Nintex Newbie

Re: Workflow to validate if Date & Time falls within a range and avoid double booking?

Jump to solution

Hi Bimi,

I haven't seen your code so cant really comment, but in theory when any user tries to save the entire saving process including checking for the duplicate through javscript should hardly take 1 or max 2 secs, so the probability of another user saving at the exact 1-2 sec window would be highly unlikely. Even then doing a double check by using your workflow should be okay as well. Its just more defensive. But in your workflow what do you do when there is a duplicate? Do you email the user back and tell them its not successful?

Where are you stuck in your workflow, from a very high level view of the workflow link it appears as though he is checking the main list (meeting rooms) and may be adding  a filter for the same room in question and just loops through records where start time is in between the start and end date. This would at least give him all the records that are clashing. The logic seems okay at a high level, where are you stuck though?

Regards,

Shrini

0 Kudos
Reply
bimi82
Nintex Newbie

Re: Workflow to validate if Date & Time falls within a range and avoid double booking?

Jump to solution
0 Kudos
Reply
bimi82
Nintex Newbie

Re: Workflow to validate if Date & Time falls within a range and avoid double booking?

Jump to solution

But in your workflow what do you do when there is a duplicate?
Do you email the user back and tell them its not successful?

Yes, the workflow needs to email the user asking to select different dates in the form.
Now, the keypoint is that the Validation Procoess needs to re-run with the new selected dates.

To achieve this, the STATE MACHINES needs to be implemented.
The issue with this is that it taked up to 5 - 10min for the worflow to go through the sate machines
It is a default timing and you cannot make it quicker ...

Now, within the 5-10 span another user could potetially claim the new selected date because he started it earlier.

Anyway need to think this through, if the WF validation is really needed??

Besides that, each request needs to be approved by the manager.
Which also means, each request with the dates gets recorded to the list but as such being reserved.

0 Kudos
Reply
bimi82
Nintex Newbie

Re: Workflow to validate if Date & Time falls within a range and avoid double booking?

Jump to solution

WHAT IS THE PROBLEM

The problem is that when I submit a request with fresh date/time which does not exisit in the table then the workflow goes through the look and identifies that the "just submitted date/time" exist and then clashes with the date!

The process is as following:

1) user opens the form

2) user selects the date

3) JS validation promps if the dates already exist

4) user submits selected dates and the workflow starts

5) worklow goes throug the loop and gatheres all the ID's and compares the dates

6) workflow identifies that the user's selected dates exist in the list (this is because he just submitted them).

In other words, the loop goes through after the form is submitted and thefore will always find the double booking
cos the data is saved into the custom list and the workflow runs which lookups in the list for dates...

it is a catch 22 situation!

How do I overcome this ...

0 Kudos
Reply
shrinivasnaik
Nintex Newbie

Re: Workflow to validate if Date & Time falls within a range and avoid double booking?

Jump to solution

Hi Bimi,

Apologies trying to balance quite a few things here so not going into very detail. I might question that we could design this in a different way.

To achieve this, the STATE MACHINES needs to be implemented.
The issue with this is that it taked up to 5 - 10min for the worflow to go through the sate machines
It is a default timing and you cannot make it quicker ... 

You mentioned you are using State Machines? Why do you use that ? State machines will run when the time job runs and that will run how it is scheduled in your SP farm. It could be 5 mins or more. Why would you want to use state machine ? You might want to start processing when the item changes and not use state machine?

regards,

Shrini

0 Kudos
Reply