I have made a deluge to create multiple records based on date as below
z = input.Total_Number_of_Sessions;
x = z - 1;
y = input.Interval_between;
var = input.Start_Date_Time.daysBetween(input.End_Date_Time);
iterationString = "".leftPad(x).replaceAll(" ",",").toList().subList(0,x);
startDatevar = input.Start_Date_Time.addDay(y);
for each index i in iterationString
{
startDatevar = startDatevar.addDay(y);
res = insert into Coach_Availability
[
Coach_Name=input.Coach_Name
Start_Date_Time=startDatevar
End_Date_Time=startDatevar.addHour(1)
Date_Time=startDatevar
Added_User=zoho.loginuser
Slot_Availability="Available"
Title = input.Title
];
}
Multiple records are created, but there is an issue in the date list
for example;
with a start_date_time of 1-Dec-2024 with interval 1 and total number of sessions 3, I expected to get 3 records with the dates 1 Dec 2024, 2 Dec 2024 and 3 Dec 2024, however I am getting records with dates 1 Dec 2024, 3 Dec 2024 and 4 Dec 2024. The record with next date after the record first date always skips a day