javascript - Cannot call method "setHtmlContent" in GAS -


i have script updates resources on or company's intranet , keep getting error: "cannot call method "sethtmlcontent" of null." can point in direction of why getting error , how fix it. thank , here code:

var domain_name = 'website.com'; var site_name = 'intranet-site'; var doc_folders = ['intranet docs/admin resources/accounts payable resources',                    'intranet docs/admin resources/finance resources',                    'intranet docs/admin resources/hr resources',                    'intranet docs/admin resources/payroll resources',                    'intranet docs/admin resources/ssp resources',                    'intranet docs/admin resources/vehicle & incident resources',                    'intranet docs/directors resources/advisory boards',                      'intranet docs/comm , pr resources/logos , graphics',                    'intranet docs/comm , pr resources/podcasts',                    'intranet docs/comm , pr resources/podcasts/enrich culture',                    'intranet docs/comm , pr resources/podcasts/visionary framework',                    'intranet docs/training , program resources/base camp',                    'intranet docs/training , program resources/phone greeting training',                    'intranet docs/training , program resources/safety program']; var web_pages = ['administration-resources/accounts-payable-resources',                  'administration-resources/finance-forms',                  'administration-resources/hr-forms-documents',                  'administration-resources/payroll-resources',                  'administration-resources/ssp-resources',                  'administration-resources/vehicle-incident-resources',                  'directors-resources/advisory-boards',                  'communication-public-relation-tools/logos-and-graphics',                  'communication-public-relation-tools/podcasts',                  'communication-public-relation-tools/podcasts/enrich-culture',                  'communication-public-relation-tools/podcasts/visionary-framework',                  'training/base-camp',                  'training/phone-greeting-training',                  'training/safety-program'];  function updateallintranetresources() {    (var idx=0; idx<web_pages.length; ++idx) {     var filescnt = updatewebpage(web_pages[idx], doc_folders[idx]);   }    return; }  function updatewebpage(webpagename, folderpath) {    logger.log('folder: ' + folderpath);   var site = sitesapp.getsite(domain_name, site_name);   var webpage = site.getchildbyname(webpagename);    var folder = docslist.getfolder(folderpath);   var files = folder.getfiles();    // begin building html web page   var htmlcontent = "<h3>resource list</h3><hr>";    // file name , url of each file in folder , add page   var filescnt = files.length;   // logger.log('nbr of files: ' + filescnt);   if (filescnt > 0) {     var = 0;     (i = 0; < filescnt; i++) {       var file = files[i];       var fileurl = file.geturl();       var filename = file.getname();       var htmlcontent = htmlcontent + '<a href="' + fileurl + '" target="_blank">' + filename + '</a><hr>';       // logger.log('(' + + ') fileurl: ' + fileurl);       // logger.log('filename = ' + filename);     }   }   else {     htmlcontent += "<b>(no resources found)</b>";   }    webpage.sethtmlcontent(htmlcontent);    return filescnt; } 

the error occurs in line

 webpage.sethtmlcontent(htmlcontent); 

the error occurs because webpage null. occur foe every web page or happen few ? also, note webpagename must see in url of browser without http://sites.google.com/a/domain_name.com/site_name/

it more useful if can paste log or execution transcript of function's execution


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -