I have a AppSheet to control somethings and send me some notificatios during the day, but I need to recive a notification on my cellphone that is trigged by a AppScript, so I tried to use the AppSheet.
I tryed to just append a row in the spreadsheet of my AppSheet, like this
function notificationAppSheet(number){
const ss = SpreadsheetApp.openById("") //the id of the SpreadSheet
const sheet = ss.getSheetByName("test")
const lr = sheet.getLastRow() + 1
sheet.insertRowBefore(lr)
var today = new Date()
var tomorow = new Date(today)
tomorow.setDate(tomorow.getDate() +1)
sheet.getRange(lr,1).setValue("New order " + number)
sheet.getRange(lr,2).setValue("logos/flexlogo.jfif")
sheet.getRange(lr,3).setValue(today)
sheet.getRange(lr,4).setValue("test@gmail.com")
sheet.getRange(lr,5).setValue(tomorow)
sheet.getRange(lr,6).setValue(true)
}
That worked to add a announcement on my app, but it don't send me a notification, despite I have a bot that send me a notification every time that a new announcement is create.
I don't need to use the AppSheet necessarily, but it's more easy than code a new app in Android I guess. Someone knows how can I send this notification with AppScript?
AppSheet doesn't 'see' the edit event when you edit the sheet using Apps Script. The app will see the new data on the next sync, but the edit event does not trigger AppSheet automations when editing the sheet directly. The edit has to be performed through the app to trigger automations.
You could use Apps Script to send a request to the AppSheet API and trigger the notification that way. Instead of updating the sheet, send that same row of data to the AppSheet API endpoint for adding a row to that table. That will trigger any automations monitoring for 'adds' in that table.
https://help.appsheet.com/en/articles/1979979-invoking-the-api