I need a way to replace part of a string with another string using Google Apps Script. I tested the following and it worked:
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; }
But, when I included it in the following code, it did not work. Any idea?
//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); } }
The script does not work as I wish. He seems to have stopped on the line:
var theURL = theURL.replace(re, replacingItem);
Additional Information: Google notified me with the following message
Details: Start Function Error Message Trigger End 1/30/13 6:51 AM onFormSubmit TypeError: Cannot find function replace in object https://plus.google.com/117520727894266469000. (line 536) formSubmit 1/30/13 6:51 AM
source share