哪些步骤将重现该问题?
- 将以下函数加载到 Google 站点中。
- 运行函数 moveblogs()。
什么是预期的输出?
我希望所有 2013 年的博客文章(公告)都将其标题记录在 Logger 中,然后移动到新的博客(公告页面)。
你看到了什么呢?
我看到了错误:
服务错误:SitesApp:内部错误(第 25 行,文件“代码”)关闭
如果可能,请提供重现问题的小示例脚本的代码:
function moveblogs() {
var fromblog = SitesApp.getPageByUrl("https://sites.google.com/a/mydomain.com/intranethome/home/Around-Intranet");
var toblog = SitesApp.getPageByUrl("https://sites.google.com/a/mydomain.com/intranethome/home/2013-around-Intranet");
var nextbloc = 0;
while (true) {
var pages2 = fromblog.getAllDescendants({"start":nextbloc,"max":100});
if (pages2.length > 0){
Logger.log("starting at.."+nextbloc+" there are .."+pages2.length+" pages starting with.."+pages2[0].getTitle());
var i = nextbloc;
for (var x in pages2) {
var publishedyear = Utilities.formatDate(pages2[x].getDatePublished(),"GMT","yyyy")
Logger.log("year: "+publishedyear);
if (publishedyear==2013) {
Logger.log("Title: "+pages2[x].getTitle());
pages2[x].setParent(toblog);
Utilities.sleep(1000);
}
i = i + 1;
}
} else {
break;
}
nextbloc = nextbloc + 100;
}
}
请在下面提供任何附加信息。
- 注释掉第 25 行可以成功记录 2012 年的博客文章。
下面的代码可以在单独的函数中移动单个博客文章:
blogpost.setParent(toblog);