I'm developing an app for an organization and they use Google Sheets a lot, about half of them uses the mobile Sheets app.
Now, I want to have an UI Alert if they change some cells' values. This works fine on the desktop browser (Chrome PC, Firefox etc..) but it doesn't work on the mobile app. I know it wouldn't work, and it's messing up my code because after the alert there are some other codes to execute, example:
function showAlert(message) {
var ui = SpreadsheetApp.getUi();
var result = ui.alert(
'Please confirm',
message,
ui.ButtonSet.YES_NO);
// Process the user's response.
if (result == ui.Button.YES) {
// User clicked "Yes".
return true;
} else {
// User clicked "No" or X in the title bar.
return false;
}
}
function Test(){
if(showAlert("Are you sure?")){
Logger.log("User says yes");
}else{
Logger.log("No");
}
}
The execution time for a function in Google App Script is 300 seconds, and while the alert didn't show, the timer continued waiting for the user input. The result is the script timed out without executing other codes, like this:
If there's a way to detect if an user is on mobile I can skip the alert so the codes can be executed, something like this
function Test(){
if( user not on mobile && showAlert("Are you sure?"){
Logger.log("User says Yes");
}
}
Is this possible? Or can I wait for 1 minute, if there's no response from the user, skip the alert and continue with other code?
