【发布时间】:2014-07-08 04:42:09
【问题描述】:
我编写了一个 Google Apps 脚本来制作一个 Google 站点模板的副本,然后为这个副本添加一个新的所有者。 我使用copySite 函数,正如文档所述,它是异步的:
复制是异步的,复制操作可能还在进行中 即使已返回对该网站的引用
站点复制完成后,我想使用addOwner 函数为站点添加一个新所有者,就像这样:
var template = SitesApp.getSiteByUrl(TEMPLATE_URL); // Retrieve the template
var copyOfTemplate = SitesApp.copySite(domain, url, googleSiteName, summary, template);
copiedTemplateURL = copyOfTemplate.getUrl();
copyOfTemplate.addOwner(adminMail); // Add the customer as owner of the new site
脚本运行良好(没有错误),创建了 Google 站点,但没有添加所有者,有时,“getUrl()”函数不返回任何内容。我尝试添加 20 秒的延迟(Utilities.sleep),但它似乎不起作用,我认为这是一个“肮脏”的解决方案。 有人能想到这种情况的解决方法吗?谢谢
【问题讨论】:
标签: google-apps-script google-sites