裏面的處理函數波紋管我試圖存儲和獲得命名的數組的數組的價值「論文」:Google Apps腳本:如何在ScriptProperties中存儲和檢索數組?
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
是不是數組的數組(按照我的意思),而是一個沒有數組的方法。
我該如何解決這個問題?如何在ScriptProperties中存儲和檢索數組?
正如@ZigMandel指出的,這個答案只是指出了一個小錯誤(包括錯誤拼寫錯誤)。更重要的是,'setProperties()'不支持除字符串以外的其他任何東西。此外,不再支持'ScriptProperties.setProperties()'及其附屬的靜態方法。 –