1

I have a small script that I have further reduced for the sake of this question. Basically it implements the onEdit function in which it may show an alert (using SpreadsheetApp.getUi().alert()) and will always show a message box (using Browser.msgBox()).

function onEdit(e) {
  const rg = e.range;

  // Do some stuff on rg and show alert if some condition is met.
  SpreadsheetApp.getUi().alert('Alert text!');

  var confirm = Browser.msgBox('Confirm','Are you sure?', Browser.Buttons.OK_CANCEL);
  if (confirm != 'ok') {
    return;
  }
  
  // Do some stuff.
}

The problem is the alert and message box are not working from Android app which compromises the whole function execution and the wanted changes do not happen. So I would like to detect if the sheet is opened from the Android app and if so skip showing the alert and message box but if a desktop browser is used, I still would like to show them.

I have browsed through the Script Services menu at Apps Script API but I did not find anything that could be used.

1

Google Apps Script services doesn't include a way to detect the if the user is using the desktop UI or the mobile app.

Possible workarounds

  • Instead of using Class UI methods like alert or prompt or Class Browser methods, set a range as a notification area and put there your messages.
  • Instead of using Google Sheets for data entry use a Google Form or create an app using Google Apps Script or AppSheet.

Related

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.