shrinivasnaik

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

Jump to solution

Just to add you are also have an approving mechanism here?

May be we design the entire thing in a different way?

1) User books the meeting room through the form

2) Form does the validation to see if the room is booked, if booked (errors out) if not booked then BOOKS it

3) Workflow will then be triggered which can send approval to manager. If approved then all is well if rejected then UNBOOK it. (similar to cancelling a meeting room!)

Scenario

1) Let User 1 add the Room 1 between 9-10 am

2) Form for User 1 does the validation (which your existing code would be handy) and books it 

3) User 1 approval goes to your manager and depending if he approves or rejects ( if you using Task based approval i.e. assign flexi task or Assign task then it will depend on the timer job to create and manage stuff for you!) In this time if User 2 tries to book in that instant then the form will throw a validation error as the room is already booked (even if its tentative)

4) if User1s manager rejects his booking then the workflow will release the booking and it will again be available for anyone else to book.

Am i missing something here?>

Regards,

Shrini

0 Kudos
Reply
shrinivasnaik

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

Jump to solution

HI Bimi,

Please refer to my earlier approach I replied to one of your questions I think the design can be a bit different ..

I just saw this reply  .. if you issue is just so that WF is trying to select the same row which the form has entered, you can add an extra check to see if the booking was made by the same person and then "not" consider this as an existing booking?

Regards,

Shrini

0 Kudos
Reply
bimi82
Contributor

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

Jump to solution

This is what it came to my mind on the way home thinking "... why does it happen" and yes, checking that the entry is NOT EQUAL current person will only check other's entries and this should work in theory

I shall test this out.

Reply
bimi82
Contributor

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

Jump to solution

My workflow is about booking a car... which is similar to booking a conference room.
Yes, that is my inttention: simply to ensure that no double booking occures.

The JS validation does the front-ent validation and the workflow does the back-end validation.
Now, either I change the query to rule out ID which are raised by CurrentUser or not to include wf validation at all?

0 Kudos
Reply
shrinivasnaik

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

Jump to solution

Sure let me know what comes out of it ..

Regards,

Shrini

0 Kudos
Reply
bimi82
Contributor

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

Jump to solution

Just to visualise the process, see below:

Attention:

+ the JS validation is a front-end validation which is triggered when filling in the form.
+ the WORKFLOW VALIDATION step is a questionmark whether it is really required etc.

Let's take two scenarios into consideration:

1) Perfect Scenario (ignore the Workflow Validation step in this case😞

- User1 requests a car on 25/11/2018 10:00 - 26/11/2018 13:00

- The request gets validated via JS and finds no overlap

- The request is now is now pending for approval
- User2 requests a car on 25/11/2018 15:00 until 25/11/2018 16:30  (which is overlapping the above)

- The JS validation of course picks it up and shows the alert message

- The user is forced to select a different date / time range!

2) Worst Scenario (ignore the Workflow Validation step in this case):

- User1 and User2 submit a request at similar timing which is a low chance but not un-avoidable!
- User1 selects 25/11/2018 10:00 - 26/11/2018 13:00
- User2 selects 25/11/2018 15:00 until 25/11/2018 16:30 

- Both requests go through without any issues because the JS validation (due timing) does not find duplicate

- Both requests will go for approval request and when they get approved = there is an overlap / doublebooking

Now this is where I thought, to implement a WORKFLOW VALIDATION step as seen in the picture (red dot). This step would then go through the list and compare the selected times, and this is where the User2 requests would be thrown back due to double booking as from what I could analyse.

When the workflow identifies a doublebooking > it informs the user to edit the form and resubmit with new date/time. For such action, a STATE MACHINE is required which can send a process back to a previous step, thus is to re-validate the request.

Or maybe... the state machine is not required because when user re-submits the request, the JS validation checks the existing entries?!

HINT:

The LOOP action contains a query and in there I will have to add (if current user is not equal created by) so that it ignores the user's fresh request otherwise it will always pick up a double booking!!

UPDATE

I have now completed the workflow as following:

1) The form validates the selected dates via the JS Validation Script
2) The workflow goes through a validation check to ensure there is no double entry in the list via Query (Current User != Created by)

3) The requests will be pending for approval requests (may add a wait until XY days and then automatically decline if it exceeds the selected date)

4) Notify the user when it has been approved or rejected and the workflow is then complete.

5) Review the request if the workflow validates a double booking and delete the request if user does not respond after 5 days.

I did not introduce StateMachines but rather in-one-line workflow.

View solution in original post

0 Kudos
Reply
shrinivasnaik

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

Jump to solution

Hi Bimi,

Thats a good depiction of the current process flow  ..

Just to be curious your only issue was that the workflow selecting its own records and you could circumvent that by quering all the records minus the current user records ? I am assuming that is sorted ?

With regards to your process flow and the workflow ..  if you have already created it then its probably better to use it.

When the workflow identifies a doublebooking > it informs the user to edit the form and resubmit with new date/time. For such action, a STATE MACHINE is required which can send a process back to a previous step, thus is to re-validate the request.

This is not required. I suggest when you see there is a double booking by the workflow you should email the user and then "END" the workflow. After the user 2 resubmits his request (the form validation would always kick in to check for any double booking) and he can resubmit for approval. A new instance of the workflow would then be triggered and can function as it should.

if that helps?

Regards,

Shrini

Reply
bimi82
Contributor

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

Jump to solution

Yes, that would be the case: to exclude the current user at the query step.

As per the State Machine, I think I will not implement it but use as a run-down flow.
When the WF finds a duplicate > it sends email to user asking to edit the form and resubmit with new date/time.
If there is no respond within 5 days then the workflow will delete the request and end the process.

0 Kudos
Reply