Skip to main content

 Hi,

 

So, I'm trying to put some basic logic on two calendars. 

Select a check-in date on Calendar1 and then if the check-out date has not been picked yet, or is before the check-in date, on Calendar2 then move it to the day ahead of the check-in date.

 

Everything works, except for when Calendar2 has not been picked. 

If you look at the attachments I've got what I think is pretty sound logic and I've checked for just about everything I could possibly think of.

 

Anybody know why it's failing?

 

TIA.


17187iFC0ABF3892538371.png
11193i2FA0E0F24485150A.png
16779i7FCBE9811F8C81ED.png

Hi Bhopes,


 


There could be a variety of methods to achieve this, but here is how I managed to do it and you can do as an alternative if you like. I did all my rules on "Submit Button"; that is- when I submit, for instance a form, the rule executes to check if my Check Out Date is empty or populated.  


 


See my solution below:


Smart Object


 



 


View


 



 


On the view, Highlight the CheckOut Date picker and configure as above image. See Expression below


 



 


In "Create Button" rules, I added the following conditions:


 



 


Condition 1


 



 


Create Method in Condition1


 



 


Condition 2


 



 


Create Method In Condition 2


 



 


After the above configuration is done, the form is ready. Below is how it would look like:


 


When the form Initiates:



 


After CheckIn Date Selected:


 



 


On the form, note that Check Out is set to the "next day" when the CheckIn Date is picked. This is because of the rules in Condition1 Create Method; that is- if CheckOut Date = Empty, then Set CheckOut Date = Expression. Remember CheckOut Date was set to Empty by default as depicted in the second image?  And the expression was created on the theird image?


 


Please have a look at how I designed my solution to help you workround your solution. I hope this gives you an idea and helps you in your solution.


 


Thanks,


Katleho


Another method in which you can create an expression that you can use to default CheckOut Date:


 


 


 


Take note of the parameters:


Add Days (CheckIn Date, Number of days to add)


 


Thanks again,


Katleho


I understand how you created those solutions, but it's not quite what I'm after. I don't want the final value to be the next day, I'm just trying to improve the user friendliness of my form. Which requires an active check to see if the Check-Out date is empty.

 

I mostly just don't understand why my logic statements is not picking up when the date picker is empty?


Hi bhopes,


 


The final value will not be the next day, it is just set to be the next day by default when the use select a CheckIn date and the user can always change it to the desired date, Just like many other property sites work for instance. So the final value is based on the user.  Also the reason why you should have the CheckOut date defaulted to the next day as soon as the user enters a CheckIn date is because there can never be a CheckIn and no CheckOut, thats how it works and it is good design to implement it like that. I am not trying to change your solution, but I just thought I could leave a tip.


 


Based on the screenshots you provided, I think the issue is that you are trying to implement rules where you are not suppose to implement them (Which is in the Expression section). Hence I provided you with an example of a small solution on my first response.


 


Expressions are meant to be used to create and return desired values based on operations performed on a combination of other values and such. E.g NextDay(CheckIn Date). This expression returns the value of the next day based on CheckIn Date so if I select 15/08/2019 as CheckIn Date, the expression returns the value of "16/08/2019". You can then use this expression value in your rules as I use it in my examples of my first response.


 


And then rules are the ones that are meant to handle the logic of your solution. E.g the "if checkOut Date = Empty, then A else B" should be done on the Rules (not Expression) section.


 


What you need to understand is the use of Expressions and Rules, and not confuse the two.


 


Let me know if I make sense.


 


Thanks,
Katleho


Hi, thanks for your breakdown.

I took your part about using rules and expressions correctly and re-evaluated how I was doing everything. The first screenshot I sent was from a rules "advanced condition"by the way, and I had the logic expressions only because I could not figure out why my advanced condition was not working. 

 

I ended up changing the advanced condition that was checking for 'less than or even to' AND 'is empty' to two seperate expressions. One advanced condition checking for 'less than or even to' and one checking if it does not contain a value. As per below.

 

I'm still not sure why that 'Is empty' check doesn't work in an advanced condition. But this is how I resolved it.

 

The reason I wanted to do it this way, instead of just a normal expressions, is that I don't want the Check-Out date changed EVERY time that Check-In is changed. For example, if a user sets a Check-In, then a Check-Out, but then wants to move the Check-In date a day or two earlier. They shouldn't be forced to re-enter their Check-Out.

 

But thanks for your help anyway guys. It lead me to the answer I wanted.


Reply