I am trying to write a merg script using goolge documents and referencing a seperate spreadsheet.
I am currently stuck, it doesn't replace any of the content and the forloop stops at i=0.
Here is the code:
function myMerger(body, myArrayOfWords, myArrayOfData){//this function will replace the terms found in myArrayOfWords with
Logger.log(' just starter myMerger');
Logger.log('myArrayOfWords.length is '+myArrayOfWords.length);
Logger.log('myArrayOfData.length is ' +myArrayOfData.length);
for(i=0;i<myArrayOfWords.length;++i){//for loop replaces will run the following code for each string within myArrayOfWords
Logger.log('myMerger forloop instance number '+i);
Logger.log('replacing '+myArrayOfWords[i]+' with '+myArrayOfData[i]);
body.replaceText(myArrayOfWords[i], myArrayOfData[i]);
//replaces the string in the document with a value from myArrayOfData
}
}
The logger returns the following:
[14-04-24 12:07:40:248 PDT] just starter myMerger
[14-04-24 12:07:40:248 PDT] myAraryOfWords.length is 23
[14-04-24 12:07:40:248 PDT] myArrayOfData.length is 23
[14-04-24 12:07:40:248 PDT] myMerger forloop instance number 0
[14-04-24 12:07:40:248 PDT] replacing **!WeekOf!** with 12
Then it stops. I can't tell if I just built a bad for loop or if there is an error that I am not aware of. I am not sure how to check for what is breaking it.