I have written a google script with an onEdit() installable trigger function, the problem is that it won’t trigger when the sheet is edited via the glide app, it does however trigger successfully when I edit the sheet manually.
Has anyone come across this issue with google sheet scripts and glide apps?
@Jeff_Hager or @Mark any ideas why it wouldn’t trigger from an update via the glide app?
As I have discussed here, onEdit() won’t work with Glide. Change it to onChange(), or trigger the event by an “on change” option in the triggers dashboard.
I have noticed that edits are being made even though I’m not touching the app or making any manual updates to any of the sheets. The label at the top of the sheet updates every now and then.
I have tried comparing the versions but no changes are coming up? could it possibly be that Glide is making some non-visible changes to the sheet in the background?
Do you have background refresh turned on in Glide? That will update a hidden metadata sheet every few minutes.
I’d also recommend an if statement at the beginning of your script to jump over the rest of the script if the current sheet is not the one you want to run the script against.
These are my Refresh settings, do you suggest changing it to ‘only on edit’?
I do have an IF statement, so the script skips any unnecessary updates/modifications, my only concern is that the script is constantly being triggered.
onChange is triggered any time the spreadsheet is touched/changed on any sheet. Like I mentioned earlier, when using "While editing or using the app’’, glide will modify the hidden App: Metadata sheet periodically which would be enough to trigger the onChange event. That’s the whole point of the Reload Sheet function. It’s so any background scripts, functions like RAND or NOW() or ImportRange can run without any user intervention to get them to update. I have a script set up similar where it will run any time there is a change in the sheet or the background refresh is turned on, but I also have an if statement to only trigger for certain sheets. I wouldn’t worry about it much unless you are getting errors from google.
This was a helpful thread! In one of my apps, I can now send a text message to a customer whenever a restaurant marks an order as “Bring Prepared” or “Ready” using a choice component.
Columns G-I of this sheet contain the phonenumer@carrier information and a message. The message column (I) is a template that contains the order status and the name of the restaurant.
I wanted to send an email (SMS message) when the status changes in Column B to either “Being Prepared” or to “Ready” (there are 4 possible statuses).
Here was the code I used:
// The column you want to check if something is entered.
var COLUMNTOCHECK = 2;
// Sheet you are working on
var SHEETNAME = 'Orders';
function sendEmails() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
//checks that we're on the correct sheet.
if(sheet.getSheetName() == SHEETNAME) {
var selectedCell = ss.getActiveCell();
var selectedRow = selectedCell.getRow();
var dataRange = sheet.getRange(selectedRow, 7, 1, 3);
var data = dataRange.getValues();
//checks the column to ensure it is on the one we want to cause the date to appear.
if(selectedCell.getColumn() == COLUMNTOCHECK) {
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[0]; // First column
if (emailAddress.match('@') === null){
continue; // skip this iteration of the loop and go to the next one
};
var message = row[2]; // Third column
if (message.match('!') === null){
continue; // skip this iteration of the loop and go to the next one
};
if (message.match('complete') !== null){
continue; // skip this iteration of the loop and go to the next one
};
var subject = 'Potluck Order Status';
MailApp.sendEmail(emailAddress, subject, message, {name:'Potluck', noReply: true});
SpreadsheetApp.flush();
}
}
}
}
Finally, had to create an onChange trigger since the spreadsheet doesn’t recognize Glide writes-to-sheets as onEdit triggers.
Thank you Bob, was also thinking that this also has something to do with the number@carrier part but I can’t figure out what the format is for our carriers here in Vietnam lol, not that I have clients in my own country so far, just wanna explore.
There are actually ways around that Rogelio. You see, this is almost the same exact way they send texts from phone to phone. You just need to find the correct @sending ending