So, I have a hotel app, or something similar, and I’m currently facing an issue. People can choose a diet, and I want to display only the diets of guests who are currently staying at the hotel. In my mind, I thought about checking if the start date is today or later, and the end date is today or earlier. If true, then the diet should be displayed; otherwise, it should not. However, since Glide doesn’t handle “if and” statements directly (at least, I don’t think it does), I attempted a solution, but it’s not working. I’m looking for some help to fix my issue, or if anyone has another idea of what I could do, I’d appreciate it.
To implement the custom code column, I first wrote a JavaScript function named isDateWithinRange
. This function takes three parameters: the current date, the start date, and the end date. It then compares the current date to the specified range and returns true if the current date is within the range, otherwise false. I encapsulated the function within a function.js
file. Accompanying this, I created a glide.json
file to define the metadata for the code, specifying the parameter types and the return type. After writing and testing the JavaScript function to ensure it performed as expected, I hosted both files on a platform that Glide could access. Finally, within the Glide table editor, I added a new Experimental Code Column, linking it to the hosted code’s URL and mapping the appropriate table columns to the function’s parameters. This integration allows my Glide app to dynamically assess and utilize date ranges directly within its interface in theory but I keep getting the error message of The manifest does not have the correct format. I’ve checked and everything should be hosted correctly on GitHub as well.
The codes I’m using:
function.js
window.function = function (currentDate, startDate, endDate) {
if (currentDate.value === undefined || startDate.value === undefined || endDate.value === undefined) {
return undefined;
}
const now = new Date(currentDate.value);
const start = new Date(startDate.value);
const end = new Date(endDate.value);
return (now >= start && now <= end) ? true : false;
}
glide.json
{
“name”: “Date Range Checker”,
“description”: “Checks if the current date is within a specified range.”,
“params”: [
{
“name”: “currentDate”,
“type”: “date-time”
},
{
“name”: “startDate”,
“type”: “date-time”
},
{
“name”: “endDate”,
“type”: “date-time”
}
],
“result”: {
“type”: “boolean”
}
}