复制Google电子表格不再复制链接表单

复制Google电子表格不再复制链接表单

本文介绍了复制Google电子表格不再复制链接表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在谷歌应用程序脚本中,制作包含链接表单的电子表格副本,用于在两个不同的Google免费客户帐户之间复制时复制链接表单。这似乎不再是这种情况。



在下面的例子中,getFormUrl返回null。

  //从第二个谷歌地址复制链接的表格以及电子表格消费者账户,通过主
的电子表格获取文件//包含链接表单的不同用户帐户的电子表格
var masterSpreadsheetFile = DriveApp.getFileById('1Jeh4b0BrF4qjogErZpd-bnnoVhLdRj2-hfwXy .....' );

//为第二个免费的Google消费者帐户用户创建副本
var copiedSpreadsheetFile = masterSpreadsheetFile.makeCopy('myCopiedSpreadsheet','MyFolder');

//设置复制链接表单的名称
var copiedSpreadsheet = SpreadsheetApp.open(copiedSpreadsheetFile);
var copiedFormUrl = copiedSpreadsheet.getFormUrl(); //在这里失败
var copiedFormId = getIdFromUrl(copiedFormUrl);
var copiedFormFile = DriveApp.getFileById(copiedFormId);
copiedFormFile.setName('myNewCopiedForm');
在此输入代码

通过同一用户帐户中的GUI复制工作表复制链接表单。

解决方案

我发现问题,必须对链接表单的权限处理进行一些更改。以前,链接表单必须继承其链接到的电子表格的权限。现在这些权限需要在表单上明确设置。因此,简单的解决方案是进入表单,添加协作者,并设置为任何有链接的人都可以编辑。

通过这一更改,当您在两个不同的Google免费客户帐户之间复制电子表格时,它也会复制链接的表单。


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.

解决方案

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.

这篇关于复制Google电子表格不再复制链接表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 19:39