Copying Google Spreadsheet no longer copies linked Form

不打扰是莪最后的温柔 提交于 2020-01-02 09:11:13

问题


In google app script, making a copy of a spreadsheet that contains a linked Form used to also copy the linked Form when you copied between two different Google free consumer accounts. That appears to no longer be the case.

In the example below, getFormUrl returns null. What is a work-around to copy the linked Form along with the Spreadsheet like it used to?

// from a 2nd google consumer account, get file by ID of a master
// spreadsheet in a different user account that contains a linked Form
var masterSpreadsheetFile = DriveApp.getFileById('1Jeh4b0BrF4qjogErZpd-bnnoVhLdRj2-hfwXy.....');

// make a copy of the master for this 2nd free google consumer account user
var copiedSpreadsheetFile = masterSpreadsheetFile.makeCopy('myCopiedSpreadsheet', 'MyFolder');

// set the name of the Copied linked Form
var copiedSpreadsheet = SpreadsheetApp.open(copiedSpreadsheetFile);
var copiedFormUrl = copiedSpreadsheet.getFormUrl(); // fails here
var copiedFormId = getIdFromUrl(copiedFormUrl);
var copiedFormFile = DriveApp.getFileById(copiedFormId);
copiedFormFile.setName('myNewCopiedForm');
enter code here

Copying a sheet via the GUI within the same user account DOES copy the linked Form.


回答1:


I found the problem, there must have been some changes made to how permissions are handled for linked Forms. Previously the linked Form must have inherited the permissions of the spreadsheet it is linked to. Now those permissions need to be explicitly set on the form. So the simple solution was to go into the form, 'add collaborators' and set to 'Anyone who has the link can edit'.

With that change, when you make a copy of a spreadsheet between two different Google free consumer accounts, it will also copy the linked Form.



来源:https://stackoverflow.com/questions/33454803/copying-google-spreadsheet-no-longer-copies-linked-form

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