Problems when using a Google spreadsheet add-on by multiple users [closed]

╄→尐↘猪︶ㄣ 提交于 2021-01-29 07:10:16

问题


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).


回答1:


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

  • https://developers.google.com/apps-script/guides/properties


来源:https://stackoverflow.com/questions/64785584/problems-when-using-a-google-spreadsheet-add-on-by-multiple-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!