哪些步骤会重现这个问题?
预期产量是多少?
我希望所有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;
}
}
请在下面提供任何其他信息。
以下代码可以在单独的函数中移动单个博文:
blogpost.setParent(toblog);
答案 0 :(得分:0)
我认为其中一个公告中的其中一个标题实际上存在问题。这个脚本有效,但可能会超时。但重新运行它只会在它停止的地方继续运行。
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.getChildren({"start":nextbloc,
"max":10,
includeDrafts: false,
includeDeleted: false,
});
if (pages2.length > 0){
Logger.log("starting at.."+nextbloc+" there are .."+pages2.length+" pages starting with.."+newblogtitle);
var i = nextbloc;
for (var x in pages2) {
var newblogtitle = pages2[x].getTitle();
//var pageType = pages2[x].getPageType();
var publishedyear = Utilities.formatDate(pages2[x].getDatePublished(),"GMT","yyyy")
if (publishedyear==2013) {
Logger.log("Title: "+ newblogtitle);
try{
pages2[x].setParent(toblog);
// Utilities.sleep(1000);
}catch(err){
Logger.log(err);
}
}
i = i + 1;
}
} else {
break;
}
nextbloc = nextbloc + 10;
}
}
}