如何使Google表格脚本在移动应用上正常工作? [英] How to get google sheets script working on mobile app?

查看:92
本文介绍了如何使Google表格脚本在移动应用上正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仔细阅读了论坛,但没有找到任何明确的答案(除了编写Android脚本,但我有iPhone)。从我在这个精彩的论坛上所读的内容来看,onEdit和onChange触发器应该可以在移动应用程序上使用。

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.

当我使用桌面应用程序时,我的脚本可以正常工作。但是,当我使用Google Sheets移动应用程序时,脚本无法运行。我如何让它们运行?

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?

解决方案是创建一个 Android添加-on ,但我有一部iPhone。也许这是一个愚蠢的问题,但是我可以在我的iPhone Google Sheets移动应用程序上运行Android插件吗?由于操作系统不兼容,所以我不做任何假设,但是发生了奇怪的事情。

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.

解决方案中添加一个脚本触发器表示要更改简单的 onEdit 触发可安装的触发器。什么是可安装的触发器?

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

解决方案表示要使用Google的Execution API创建一个网络应用。不知道该怎么做。我以为我已经做了。在脚本编辑器中> 发布> 作为Web应用程序部署。我还完成了发布> 部署为API可执行文件。我做错了吗?

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?

我的脚本:

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";
    }
  }  


推荐答案

不确定我做了什么,但是现在我的 onEdit 触发器可以在移动设备上使用了!可能一直在激活部署为API可执行文件并延迟激活?不知道发生了什么,但是现在 onEdit 触发器起作用了,我从Google表格中收到带有失败报告的电子邮件。不确定触发成功后,为什么Google Sheets会向我发送失败报告,但是现在我不会抱怨它起作用了!

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();
}

如果触发器在iPhone Google Sheets应用程序上不起作用,请尝试激活作为API可执行文件部署。在脚本编辑器的发布下找到该文件,并将安装代码添加到脚本中

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

这篇关于如何使Google表格脚本在移动应用上正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆