Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing Google Apps Script Functions from Mobile App

I'm developing a interface for a user who uses a google spreadsheet as his database. Nowadays he uses the Google Sheet mobile App (Android and IOs) to update his spreadsheet, and I just can't find any way to create a interface or even call a function on the mobile app. Does anyone knows how can I call a function from the script I've created on the Google Sheets Mobile app? Thanks!

like image 411
Felipe Lemos Avatar asked Oct 27 '15 16:10

Felipe Lemos


2 Answers

The following work with the mobile versions of Google sheets:

  • Custom functions
  • onEdit simple/installed trigger
  • onChange trigger
  • onSelectionEvent trigger(Works partially, if sheets is also open in desktop)

Notes:

  • Avoid calls to get active: getActive() sheet, range or cell. These don't work in mobile or they return a default value like A1 in the first sheet for range.

  • Avoid calls to ui: getUi(). These have no meaning in the context of mobile app and won't work. This includes calls to alerts/prompts. More than likely, You'll hit execution timeout because alerts will wait for user input and this won't show up in mobile. If you do want to show some message, Here is a excellent workaround using images to do the same.

    • Avoid calls to HtmlService. Sidebars/Modal dialogs are not supported in mobile versions.

    • Buttons/Menu items don't work.

  • The best way to support apps script is mobile apps is to chain onEdit calls to a checkbox. Click here for a sample.

like image 90
TheMaster Avatar answered Sep 19 '22 23:09

TheMaster


Update Sep-2020

This answer might not be relevant anymore, since Google changed a lot of things in the past year.


You cannot execute Google App Script functions (gas functions) via Google Sheets mobile app.

Alternative #1: (deprecated as of June 2019 - this is no longer possible)

Create Android Add-on

Source: https://developers.google.com/apps-script/add-ons/mobile/

Android add-ons can utilize the Apps Script Execution API to directly call functions in Apps Script projects. This allows Android add-ons to retrieve and manipulate data from a Google Doc or Sheet using standard Apps Script techniques. Just like desktop add-ons, Android add-ons allow you to craft custom user interfaces — but with the full capabilities of the Android platform at your disposal.

Alternative #2

Create a web-app and use Google's Execution API

Source: https://developers.google.com/apps-script/guides/rest/api

The Apps Script Execution API consists of a single scripts resource, which has a single method, run, that makes calls to specific Apps Script functions

like image 23
Meir Gabay Avatar answered Sep 20 '22 23:09

Meir Gabay