Calendar - Start & End Dates - automatically populate the dates in between

Calendar - Start & End Dates - automatically populate the dates in between

I wanted to use ZOHO Creator to build a holiday request system for my team, so they can request holidays, I can approve them and they can see everyone's bookings on a calendar view. However - I ran into the same problem that it looks lilke many 'Zoho-ers' have come across in the past.....at best you can register a START and END date in a calendar view.....but difficult to get the days in the middle - without manually entering a record for every day.

Having looked through the forums & discussion boards, I couldn't find any real help in solving what seems to have been a problem for several years.

The fact that Creator Calendar is fine if you (A) only want a monthly view (B) only want to enter single day events and (C) can live with only short text fields appearing in the view.

I knew I would have to wait for Zoho to develop parts (A) & (C) - but part (B) seemed something that could be achieved with Deluge script.

So here was my solution....

I built a FORM called 'Master Year Calendar' with two fields, (I'll explain this form later)

DATE FIELD (Date) - Unique
WORK DAY (Decision Box)

Another form called BANK HOLIDAY with two fields (this will store a record of public holidays - Christmas Day etc)
BANK HOLIDAY (Date) -Unique
Description (String)


Then added some script to the Master Year Calendar
  1.  actions
  2.     {
  3.         on add
  4.         {
  5.             Submit
  6.             (
  7.                 type  =  submit
  8.                 displayname  =  "Submit"
  9.                 on success
  10.                 {
  11.                     if ((input.Date_field.getDayOfWeek()  =  7)  ||  (input.Date_field.getDayOfWeek()  =  1))
  12.                     {
  13.                         input.WorkDay = false;
  14.                     }
  15.                     rec  =  Bank_Holiday  [Bank_Holiday == input.Date_field];
  16.                     if (rec.Description  !=  null)
  17.                     {
  18.                         input.WorkDay = false;
  19.                     }
  20.                 }
  21.             )
What this does is : for every date entered into the FORM, it checks whether it is a working day (Monday to Friday) and whether it is a public holiday. If it is not a weekend and not a public holiday, the check box for 'Work Day' is set to true.

Now the boring bit, I got someone to add in 365 records, one for each day of the year - only took about 15 minutes using a calendar view to simply add a record per day. Couldn't find any way to do this by code - which is not surprising as this is the fundamental problem with using Zoho Calendar to display multi day events - the fact there is no concept of For-Next loop or Do-While.

So now I have a master FORM, with a record for every day of the year and a flag if that day is a working day.....

I then Build my Holiday Request Form

Resource (Dropdown list of staff names - could be a lookup of all employees form another form)
Start Date (Date)
End Date (Date)
Approved (Decision) - only visible when using my USERID

I then add another FORM : Holiday Calendar Bookings - this is the form that will actually store the dates of approved holidays.

Resource (Single Line)
Date (Date)
Work Day (Decision Box)

Now the key bit of script that makes this worthwhile....

Added 'On Edit' script to the Holiday Request form, such that, if I change the status to 'APPROVED=TRUE' - it will then auto-populate every date of the holiday for an individual in  Holiday Calendar Bookings. It does this by using the Master Year Calendar to act a pseudo ' Do While Loop'

The code explanation is : 

Set two variables: START (one day before the first day of their holiday) and END (one day after their holiday finishes)
Then if the record (holiday is approved).....loop the the 'Master Year Calendar' which now has every day of the year in it and if the holiday request matches a particular day of the year, then add an entry into the Holiday Calendar Bookings, I also populate whether it is a working day or not, because in another form, I count up how many holidays days, that are working days an employee has used, to calculate their holiday balance.

[ I know you can code the selection slightly differently by doing 
for each rec in Master_Year_Calendar  [(Date_field >= input.Date_From && Date_field <=input.Date_To)]
but I like to use variables where appropriate, such that reading the code later is slightly easier]

  1. Start = input.Date_From.addDay(-1);
  2. End = input.Date_To.addDay(1);
  3. if (input.Approved)
  4. {
  5.     for each rec in Master_Year_Calendar  [(Date_field > Start && Date_field < End)]
  6.     {
  7.         insert into Holiday_Calendar_Bookings
  8.         [
  9.             Resource = input.Resource
  10.             Date_field = rec.Date_field
  11.             Added_User = zoho.loginuser
  12.             Working_Day = rec.WorkDay
  13.         ]
  14.     }
  15. }
Yes this code does loop through 365 records to sometimes only add three records into your final FORM, but (A) it's server side and (B) it processes instantly.

What you end up with is the basis of a system that you can specify a start and end date and have all the inclusive dates in that period populated, such that a calendar view can easily be used for showing bookings etc.

The image below shows that from just two 'Holiday Requests' one form Neil and one from Marianne, when they were approved, the full dates were populated into the calendar.




Hope someone finds this useful, as it is a routine/approach, I am very likely to use again & again.

Thanks




    Access your files securely from anywhere







                            Zoho Developer Community





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                   
                                                    

                                                  Videos

                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner






                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner






                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources


                                                                                              Zoho Writer Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ








                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方




                                                                                                            • Recent Topics

                                                                                                            • Cant Save Gauge on Creator Page

                                                                                                              How to Save Gauge on Creator Page see movie https://vimeo.com/1116410860?share=copy#t=0
                                                                                                            • Update application by uploading an updated DS file

                                                                                                              Is it possible? I have been working with AI on my desktop improving my application, and I have to keep copy pasting stuff... Would it be possible to import the DS file on top of an existing application to update the app accordingly?
                                                                                                            • Granular Email Forwarding Controls in Zoho Mail (Admin Console and Zoho One)

                                                                                                              Hello Zoho Mail Team, How are you? At present, the Zoho Mail Admin Console allows administrators to configure email forwarding for an entire mailbox, forwarding all incoming emails to another address. This is helpful for delegation or backup purposes,
                                                                                                            • Change Currency symbol

                                                                                                              I would like to change the way our currency displays when printed on quotes, invoices and purchase orders. Currently, we have Australian Dollars AUD as our Home Currency. The only two symbol choices available for this currency are "AU $" or "AUD". I would
                                                                                                            • Auto Capitalize First Letter of Words

                                                                                                              Hi I am completely new to ZOHO and am trying to build a database. How can i make it when a address is entered into a form field like this: main st it automatically changes is to show: Main St Thank You
                                                                                                            • Follow-up emails via Workflow Automation not staying in the same thread

                                                                                                              Dear Zoho Support Team, I am currently using Workflow Automation in Zoho Campaigns to send follow-up emails. In my test case, I noticed the following behavior: All emails in the automation have the same subject line. If the follow-up email is sent within
                                                                                                            • Client Script refuses to set an initial value in Subform field

                                                                                                              I tried a very simple, 1 line client script to set a default value in a custom subform field when the "Add Row" button is clicked and the user is entering data. It does not work - can someone tell me why? ZDK documentation suggests this should be doable.
                                                                                                            • Archiving Contacts

                                                                                                              How do I archive a list of contacts, or individual contacts?
                                                                                                            • How do I filter contacts by account parameters?

                                                                                                              Need to filter a contact view according to account parameter, eg account type. Without this filter users are overwhelmed with irrelevant contacts. Workaround is to create a custom 'Contact Type' field but this unbearable duplicity as the information already
                                                                                                            • Send / Send & Close keyboard shortcuts

                                                                                                              Hello! My team is so close to using Zoho Desk with just the keyboard. Keyboard shortcuts really help us to be more efficient -- saving a second or two over thousands of tickets adds up quickly. It seems like the keyboard shortcuts in Desk are only for
                                                                                                            • Zoho Social - Post Footer Templates

                                                                                                              As a content creator I often want to include some information at the end of most posts. It would be great if there was an option to add pre-written footers, similar to the Hashtag Groups at the end of posts. For example, if there is an offer I'm running
                                                                                                            • Zoho Expense - The ability to add detail to a Trip during booking

                                                                                                              As an admin, I would like the ability to add more detail to the approved Trips. At present a requestor can add flights, accommodation details and suggest their preferences. It would be great if the exact details of the trip could be added either by the
                                                                                                            • Simplified Call Logging

                                                                                                              Our organization would like to start logging calls in our CRM; however, with 13 fields that can't be removed, our team is finding it extremely cumbersome. For our use case, we only need to record that a call happened theirfor would only need the following
                                                                                                            • Week date range in pivot table

                                                                                                              Hello, I need to create a report that breakouts the data by week.  I am using the pivot table report, and breaking out the date by week, however the date is displayed as 'Week 1 2014' format.  Is there anyway to get the actual dates in there? ex. 1/6/2014-1/12/2014 Thanks,
                                                                                                            • Help Center IFrame Issue

                                                                                                              I have had a working Help Center on my website using an iframe for a while. But now for some reason the sign in page gets a refused to connect error. Can someone please help. If I go to the url manually it works correclty
                                                                                                            • Staff rules

                                                                                                              Hi! Do you people know what are the default staff rules when a new booking is created? We have two staff members in my team (me as the admin, and my employee). As we share the same services, I'm wondering how Zoho will pick the staff for new apointments.
                                                                                                            • Comment Templates

                                                                                                              Is it possible to add a template option for comments? We have some agents in the process who's responses require a pre-formatted layout. It would be incredibly handy to have a template for them where they can insert the template and then add their responses
                                                                                                            • [ZohoDesk] Improve Status View with a new editeble kanban view

                                                                                                              A kanban view with more information about the ticket and the contact who created the ticket would be valueble. I would like to edit the fields with the ones i like to see at one glance. Like in CRM where you can edit the canvas view, i would like to edit
                                                                                                            • Adding Markdown text using Zoho Desk API into the Knowledge Base

                                                                                                              Hi Zoho Community members, We currently maintain the documentation of out company in its website. This documentation is written in markdown text format and we would like to add it in Zoho Knowledge Base. Do you know if there is REST API functionality
                                                                                                            • An Exclusive Session for Zoho Desk Users: AI in Zoho Desk

                                                                                                              A Zoho Community Learning Initiative Hello everyone! This is an announcement for Zoho Desk users and anyone exploring Zoho Desk. With every nook and corner buzzing, "AI's here, AI's there," it's the right time for us to take a closer look at how the AI
                                                                                                            • Shared values: From classroom lessons to teaching moments in customer service

                                                                                                              While the world observes Teachers’ Day on October 5, in India, we celebrate a month earlier, on September 5, to mark the birth anniversary of Dr. Sarvepalli Radhakrishnan, a great teacher, renowned scholar, educationist, and advocate for empowerment.
                                                                                                            • Export to excel stored amounts as text instead of numbers or accounting

                                                                                                              Good Afternoon, We have a quarterly billing report that we generate from our Requests. It exports to excel. However if we need to add a formula (something as simple as a sum of the column), it doesn't read the dollar amounts because the export stores
                                                                                                            • Image Upload Field | Zoho Canvas

                                                                                                              I'm working on making a custom view for one of our team's modules. It's an image upload field (Placement Photo) that would allow our sales reps to upload a picture of the house their working on. However, I don't see that field as a opinion when building
                                                                                                            • Create a list of customers who participated in specific Zoho Backstage events and send them an email via Zoho CRM

                                                                                                              How to create a list of customers who participated in specific Zoho Backstage events and send them an email via Zoho CRM? I was able to do a view in CRM based on customer that registered to an event, but I don't seems to be able to include the filter
                                                                                                            • Custom Button Disappearing in mobile view | Zoho CRM Canvas

                                                                                                              I'm working in Zoho CRM Canvas to create a custom view for our sales team. One of the features I'm adding is a custom button that opens the leads address in another tab. I've had no issue with this in the desktop view, but in the mobile view the button
                                                                                                            • Zoho Desk blank page

                                                                                                              1. Click Access zoho desk on https://www.zoho.com/desk/ 2. It redirects to https://desk.zoho.com/agent?action=CreatePortal and the page is blank. Edge browser Version 131.0.2903.112 (Official build) (arm64) on MacOS
                                                                                                            • Clearing Fields using MACROS?

                                                                                                              How would I go about clearing a follow-up field date from my deals? Currently I cannot set the new value as an empty box.
                                                                                                            • I hate the new user UI with the bar on the left

                                                                                                              How can I reverse this?
                                                                                                            • Constant color of a legend value

                                                                                                              It would be nice if we can set a constant color/pattern to a value when creating a chart. We would often use the same value in different graph options and I always have to copy the color that we've set to a certain value from a previous graph to make
                                                                                                            • Office 365 and CRM mail integration: permission required

                                                                                                              Has anyone run into this weird problem? My email server is Office 365. When I try to configure Zoho CRM to use this server, a Microsoft popup window opens requesting user and password. After entering that, I get a message in the Microsoft window saying
                                                                                                            • Field Not Updating in FSM Script - Service and Parts module.

                                                                                                              Dear Team, I am reaching out regarding a script I have implemented in Zoho FSM to automate the calculation of the End of Service date based on the End of Sale date in the Service and Parts module. Overview of the script: Fetches the End_of_Sale__C and
                                                                                                            • Question regarding import of previous deals...

                                                                                                              Good afternoon, I'm working on importing some older deal records from an external sheet into the CRM; however, when I manually click "Add New Deal" and enter the pertinent information, the deal isn't appearing when I look at the "Deals" bar on the account's
                                                                                                            • Client Script also planned for Zoho Desk?

                                                                                                              Hello there, I modified something in Zoho CRM the other day and was amazed at the possibilities offered by the "Client Script" feature in conjunction with the ZDK. You can lock any fields on the screen, edit them, you can react to various events (field
                                                                                                            • One person/cell phone to manage multiple accounts

                                                                                                              Hi. I have a personal Free account to keep my own domain/emails. Now I need to create a Business account to my company's own domain, but I have only one mobile phone number I use to everything. How do I do to manage this? Can I manage a Free domain and
                                                                                                            • Tracking KPIs, Goals etc in People

                                                                                                              How are Zoho People users tracking employee targets in People? For example, my marketing assistant has a target of "Collect 10 new customer testimonials every month". I want to record attainment for this target on a monthly basis, then add it to their
                                                                                                            • Zoho Desk: Ticket Owner Agents vs Teams

                                                                                                              Hi Zoho, We would like to explore the possibility of hiding the ‘Agents’ section within the Ticket Owner dropdown, so that we can fully utilise the ‘Teams’ dropdown when assigning tickets. This request comes from the fact that only certain agents and
                                                                                                            • CRM limit reached: only 2 subforms can be created

                                                                                                              we recently stumbled upon a limit of 2 subforms per module. while we found a workaround on this occasion, only 2 subforms can be quite limiting in an enterprise setting. @Ishwarya SG I've read about imminent increase of other components (e.
                                                                                                            • Can not Use Attachment Button on Android Widget

                                                                                                              this always pops up when I touch the attach button on android widget. going to settings, there is no storage permission to be enabled. if I open the app, and access the attach feature there, I can access my storage and upload normally.
                                                                                                            • Can I add Conditional merge tags on my Templates?

                                                                                                              Hi I was wondering if I can use Conditional Mail Merge tags inside my Email templates/Quotes etc within the CRM? In spanish and in our business we use gender and academic degree salutations , ie: Dr., Dra., Sr., Srta., so the beginning of an email / letter
                                                                                                            • Zoho Notebook Sync problem

                                                                                                              I'm facing a problem with syncing of notebook on android app. It's not syncing. Sometimes it syncs after a day or two.  I created some notes on web notebook but it's not syncing on mobile app. Please help!!!!
                                                                                                            • Next Page