zohozoho-deluge

I need to write a custom function in Zoho people Deluge to fetch all the dates between from and to given


I need to write a custom function in Zoho People Deluge to fetch all the dates between from and given. Example: from 01-Dec-2023 to 03-Dec-2023. I also need to get 01-dec-2023, 02-dec-2023, 03-dec-2023. The looping must create an entry in some form.

I tried with for and while loops but I'm always getting errors:

Code: `

Calculate the number of days between the two dates no_of_days = repeat_from.daysBetween(repeat_upto);

Initialize the current day to the start date current_day = repeat_upto;

Create an array to store dates date_array = List();

Populate the array with each day in the range using a for loop for (i = 0; i <= no_of_days; i = i + 1) date_array.add(current_day.addDays(i));

Now 'date_array' contains all the dates in the range info date_array;``

Error: Syntax error. Expecting ',' or ')'. Found ';'.

Output needed: Need to create entries in the form: request_form with all three dates.


Solution

  • In Zoho Deluge, while loops are not supported, and only for-each loops can be used, particularly with lists. The code you provided is attempting to create a list (DummyList) based on the difference in days between two dates (Date1 and Date2), and then iterates over this list to perform some logic.

    Date1 = '10-1-2023';
    Date2 = '10-15-2023';
    
    days = Date1.daysbetween(Date2);
    
    ///////////////////---------creating DummyList
    DummyText = "".leftpad(days + 1);
    DummyList = DummyText.toList("");
    
    count = 0;
    for each dummy in DummyList
    {
        LoopDate = Date1.addDay(count);
        ///////////////////----------------write insert logic
        info LoopDate ;
        
        count += 1;
    }
    
    

    This code calculates the number of days between Date1 and Date2 and then creates a list (DummyList) with that number of elements. It iterates through this list, adding each day to Date1, and then logs the result (LoopDate).

    Remember, the actual insert logic should replace the info LoopDate line. The code provided is a skeleton, and you need to add the specific logic for inserting into your form