多个用户使用Google电子表格加载项时出现问题 [英] Problems when using a Google spreadsheet add-on by multiple users

查看:179
本文介绍了多个用户使用Google电子表格加载项时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在针对Google表格的自行开发的加载项中,添加了功能,即根据表中的选择,将通过侧栏中的JavaScript音频播放器播放声音文件.有关代码本身,请参见

当用户从Marktetplace安装了附件时,该附件一次仅对一个用户有效:更改选定的行时,将通过播放器自动播放(自动启动)相应的声音文件.右侧.

但是,当几个用户正在使用此附加组件时,各个浏览器中的音频播放器似乎会相互干扰,从而音频文件被中断并会重新开始直到再次被中断为止,因此最终中断音频文件的循环.因此,问题似乎在于,由多个用户运行加载项正在永久中断并重新启动脚本.

我确实不知道从哪里开始调查此错误.我发现,在多用户模式下,一遍又一遍地启动了用于传递声音文件的PHP脚本.

在单用户模式下,此脚本仅被调用一次.

可访问的示例可在此处进行访问.附件>播放音频"(需要Google帐户).要重现该错误,必须将工作表打开两次(例如,在两个浏览器中).

解决方案

查看已接受的答案上的代码在表中选择下一行时,在电子表格侧栏中更新值问题是由于使用了脚本属性存储而引起的因为任何打开侧边栏的用户都将覆盖脚本属性.

解决方案是使用用户属性存储.换句话说,

代替

  PropertiesService.getScriptProperties() 

使用

  PropertiesService.getUserProperties(); 

资源

In a self-developed add-on for Google Sheets, the functionality has been added that a sound file will be played from a JavaScript audio player in the side bar, depending on the selection in the table. For the code itself see here.

When users have installed the add-on from the Marktetplace, the add-on works fine only for one user at a time: When the selected row is changed, the corresponding sound file is played automatically (autostart) through the player on the right-hand side.

However, when several users are using this add-on, the audio players in the respective browsers seem to interfere with each other, such that the audio file is interrupted and will start again until is interrupted again, thus, ending up with a loop of interrupting audio files. The problem thus seems to be that running the add-on by more than one user is interrupting and restarting the script permanently.

I do have absolutely no idea where to start investigating this error. What I found out is that, in the multi-user mode, the PHP script to deliver the sound file is started over and over again.

When in single-user mode, this script is only called once.

A reproducible example is accessible here; Add-ons > 'play audio' (Google account necessary). To reproduce the error, the sheet has to be opened two times (e.g. in two browsers).

解决方案

Looking at the code on the accepted answer to Update value in a spreadsheet sidebar when next row is selected in table the problem is caused due to the use of the Script Properties store because any user that open the sidebar is overwriting the script properties.

The solution is to use the User Properties store. In other words,

instead of

PropertiesService.getScriptProperties()

use

PropertiesService.getUserProperties();

Resources

这篇关于多个用户使用Google电子表格加载项时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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