Hello, I am trying to setup a scheduling page where when a start date, recurrence pattern (1 for every day, 7 for weekly), and number of sessions (i.e 3) is provided, the remaining two dates are returned as an array.
function calculateSchedule() {
const startDate = new Date(p1);
const recurrenceDays = parseInt(p2, 10);
const numSessions = parseInt(p3, 10);
let schedule = [];
for (let i = 1; i < numSessions; i++) {
let nextSessionDate = new Date(startDate.getTime() + recurrenceDays * 86400000 * i);
schedule.push(nextSessionDate.toISOString());
}
return schedule;
}
const output = calculateSchedule();
output;
Glide Docs has info on the experimental column but nothing for the javascript column. In testing, I noticed console.log does not provide an output in the javascript column (duh); but it makes me think if there are other limitations within the javascript column? (Besides limited parameters.)
You are not passing your parameters as p1, p2, or p3, so your parameters aren’t being used in your code.
You are not calling the function in your code, so it’s not even going to run.
You can’t return arrays from a javascript column. You will have to convert it to a comma delimited string first, return the string, then use a Split Text column to convert it to an array.
For starters, add a function call like this outside of the function. return generateSessionSchedule(p1, p2, p3);