如何在ScriptProperties中存储和检索数组?

 留心6_136 发布于 2023-02-11 06:07

在处理程序函数内部我正试图存储并获取名为"theses"的数组数组的值:

 var fact_list = [ ["Kennedy Inauguration", "politics", "tZwnNdFNkNklYc3pVUzZINUV4eUtWVWFSVEf"], ["Pericles’ Funeral Oration", "politics", "sdgrewaNkNklYc3pVUzZINUV4eUtW345ufaZ"], ["The Pleasure of Books", "culture", "1234rFszdgrfYc3pVUzZINUV4eU43usacd"], ["I Am The First Accused (Nelson Mandela)", "law", "34rsgadOsidjSZIswjadi95uydnfklsdks"] ];
function submit(e){
  Logger.log("running submit(e)"); 
  var numberOfItems = e.parameter.checkbox_total;
  var itemsSelected = [];
  // for each item, if it is checked / selected, add it to itemsSelected
  for(var i = 0; i < numberOfItems; i++){
    if(e.parameter['checkbox_isChecked_'+i] == 'true'){
      itemsSelected.push(e.parameter['checkbox_value_'+i]);
    }
  }
  var app = UiApp.getActiveApplication();

  Logger.log("itemsSelected = " + itemsSelected);

  ScriptProperties.setProperties({'theses': itemsSelected}, true); 


  var thesesArrays = ScriptProperties.getProperty('theses');
  Logger.log("thesesArrays = " + thesesArrays);
  for (var i = 0; i < thesesArrays.lenght(); i++){
       var thesesId = ScriptProperties.getProperty('theses')[i][2];
       var thesesType = ScriptProperties.getProperty('theses')[i][1];
       importTheses(target, thesesId, thesesType);
}       
  app.close();
  return app;
}

但是当代码得到行时for (var i = 0; i < thesesArrays.lenght(); i++){我得到了一个错误,因为thesesArrays它不是一个数组数组(正如我的意图),而是一个没有该lenght()方法的对象.

我该如何解决这个问题?如何在ScriptProperties中存储和检索数组?

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有