0

I've perused the forum and haven't found any definitive answers (other than to write an Android script, but I have an iPhone). From what I've read on this wonderful forum, the onEdit and onChange triggers should work on the mobile app.

My script works fine when I use the desktop app. However, when I use the Google Sheets mobile app, the scripts do not run. How can I get them to run?

This solution was to create an Android add-on, but I have an iPhone. Maybe this is a stupid question, but can I run an Android add-on on my iPhone Google Sheets mobile app? I'd assume no since the OSs are incompatible, but weirder things have happened.

This solution says to change the simple onEdit trigger to an installable one. What is an installable trigger?

This solution says to create a web-app using Google's Execution API. Not sure how to do this.. I thought I already did. Within script editor> Publish > Deploy as web app. I've also done Publish > Deploy as API executable. Am I doing something wrong?

Does this mean scripts just don't work on the iOS Google Sheets mobile app?

My script:

function onEdit(){
  var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("pss");
  var lr = ss.getLastRow();
  var range = ss.getRange("A2:J" + lr);
  var vlst = range.getValues();

  range.setValues(vlst);
  var i,j,a,find,repl;
   for (var i = 0; i < vlst.length; i++){
    for (var j = 0; j < vlst[i].length; j++){
      a = vlst[i][j];
      if (a == find) vlst[i][j] = repl; 
    find ="sun";
    repl ="sunshine";
    }
  }  
que syrah sarah
  • 231
  • 1
  • 4
  • 14
  • Capitalization matters. `OnEdit` is not a reserved ["simple trigger"](https://developers.google.com/apps-script/guides/triggers/) function name, while `onEdit` is. There are also some syntax errors that should prevent your script from even saving. – tehhowch Aug 14 '18 at 18:41
  • apologies, i changed it (after reading an answer that said just removing and re-adding the function worked). it still does not work when lower case `onEdit` i'll update my post to reflect the correct capitalization and other changes i made. however, my script saves and runs fine, but i have to manually run it. it does not automatically trigger on edit. i even tried `onChange` and it does not work on my PC unless manually run. at least the onEdit works automatically on my PC – que syrah sarah Aug 14 '18 at 20:45
  • even odder - when i go into the mobile app, after i enter something into a cell, it undoes it. i've tried multiple times and any edits get undone. however, when i go into the PC app, i can edit cells just fine. what's going on?? – que syrah sarah Aug 14 '18 at 20:51
  • Not sure what i did, but now my `onEdit` trigger works on mobile! might have been activating `Deploy as API executable` and it just took a few hours to apply? Not sure what worked, but now the `onEdit` trigger works and I'm getting emails from Google Sheets with fail reports. Not sure why it's sending me fail reports when the trigger is successful, but I'm not going to complain now that it works! – que syrah sarah Aug 16 '18 at 16:11
  • Please check [this](https://webapps.stackexchange.com/questions/87346/add-a-script-trigger-to-google-sheet-that-will-work-in-android-mobile-app). I guess it solves the problem. – Péter Baráth Oct 08 '19 at 13:33

1 Answers1

1

Not sure what I did, but now my onEdit trigger works on mobile! Might have been activating Deploy as API executable with delayed activation? Not sure what happened, but now the onEdit trigger works and I'm getting emails from Google Sheets with fail reports. Not sure why Google Sheets is sending me fail reports when the trigger is successful, but I'm not going to complain now that it works!

What also might be the solution was that I added the installation code:

function createTriggers() {
  ScriptApp.newTrigger('onMyEdit')
    .forSpreadsheet(SpreadsheetApp.getActive())
    .onEdit()
    .create();
}

If your triggers aren't working on the iPhone Google Sheets app, then try activating Deploy as API executable. It's found within the Script Editor under Publish and also add the installation code to your script

que syrah sarah
  • 231
  • 1
  • 4
  • 14