【发布时间】:2013-01-28 23:29:01
【问题描述】:
我需要一种使用 Google Apps 脚本将字符串的一部分替换为另一个字符串的方法。我测试了以下内容并成功:
function test(){
var value = 'https://plus.google.com/117520727894266469000';
var googleimageURL = googlePlus(value);
Logger.log('Returned Result: ' + googleimageURL);
}
function googlePlus(value){
var apiKey = ScriptProperties.getProperty('apiKey');
var re = 'http://'
var theURL = value;
Logger.log('Google+ is called: ' + value);
var replacingItem = 'https://';
var theURL = theURL.replace(re, replacingItem);
Logger.log('Google+ Values 2: ' + value + ' : ' + theURL + ' after ' + replacingItem);
return imageURL;
}
但是,当我嵌入以下代码时,它不起作用。有什么想法吗?
//If a Google+ column was not specified,put a flag.
if (googleColumn && column == googleColumn) {
if (value == ""){
columns.push(nogoogleColumn);
values.push(flag);
var googleimageURL="";
} else {
var googleimageURL = googlePlus(value);
Logger.log('Returned Result: ' + googleimageURL);
}
}
脚本没有按我希望的那样工作。它似乎停在以下行:
var theURL = theURL.replace(re, replacingItem);
附加信息:Google 通过以下消息通知我
提交表单
TypeError:在对象 https://plus.google.com/117520727894266469000 中找不到函数替换。 (第 536 行)表单提交
【问题讨论】:
标签: javascript google-apps-script triggers