Cognito-forms – Is it possible to link one calendar to another inside the same form

cognito-forms

For example I am creating a form for a custom media production order for a radio station. I have figured out how to get the calendar to skip to three days ahead (the earliest a customer's audio could be ready) for the "Order Start Date" – the earliest day the order can start is three days from the form submission.

However, if the customer selects that they would like "pre approval" of their audio, a calendar pops up with the date they want their proof, and that then goes into the e-mail for our production guys. Thing is, the "order start date" then can't be until two days after pre-approval if the customer wants it. So if say, the customer says they want to pre-approve their audio, then selects a pre-approval date of 8/1 on the calendar that pops up when they click "yes" for pre-approval, I would like the "Order Start Date" to black out to 8/3, not just three days from when then form is submitted.

I'm trying to figure out the logic to get one calendar to call another calendar on the same form.

Is it possible?

Best Answer

I'm a developer with Cognito Forms.

Yes you can do reference another calendar, but it sounds like you have one Minimum value on your Order Start Date and you will then want to replace it with the new Minimum value that would be provided by the 'Pre-approval Date' when its showing.

To do this I created a simple from with just 3 fields.

  • A Yes/No field titled 'Pre-approve audio' that is always visible.
  • A Date field titled 'Order start date'that is always visible.
  • Then another Date field titled 'Pre-approval date' that is only visible when the Yes/No filed, 'Pre-approved audio' is set to yes.

The 'Order start date' then has the following code in the 'Minimum' range value.

=PreapproveAudio ? PreapprovalDate.AddDays(2) : DateTime.Today.AddDays(3)

This will set the date field to check the Yes/No field, and use one of the two minimum dates. If 'Yes' is selected the minimum value cant be before the date in the 'Pre-approval date' + 2 days. If 'No' is selected the minimum value cant be before today's date + 3 days.

I have included a link to my template so that you can copy this form into your Organization and take a look at how the calculations are working.

Linking Calendars template