0

または会社のイントラネット上のリソースを更新するスクリプトを使用していますが、「null のメソッド "setHtmlContent" を呼び出せません」というエラーが発生し続けます。このエラーが発生する理由と修正方法を教えてください。ご協力ありがとうございます。コードは次のとおりです。

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 and PR Resources/Logos and Graphics',
                   'Intranet Docs/Comm and PR Resources/Podcasts',
                   'Intranet Docs/Comm and PR Resources/Podcasts/Enrich Culture',
                   'Intranet Docs/Comm and PR Resources/Podcasts/Visionary Framework',
                   'Intranet Docs/Training and Program Resources/Base Camp',
                   'Intranet Docs/Training and Program Resources/Phone Greeting Training',
                   'Intranet Docs/Training and 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() {

  for (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 for web page
  var htmlContent = "<h3>Resource List</h3><hr>";

  // Get file name and url of each file in folder and add to page
  var filesCnt = files.length;
  // Logger.log('Nbr of files: ' + filesCnt);
  if (filesCnt > 0) {
    var i = 0;
    for (i = 0; i < 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('(' + i + ') fileUrl: ' + fileUrl);
      // Logger.log('fileName = ' + fileName);
    }
  }
  else {
    htmlContent += "<b>(no resources found)</b>";
  }

  webpage.setHtmlContent(htmlContent);

  return filesCnt;
}
4

1 に答える 1