0
我試圖簡單地使用市場列表填充多選字段。NetSuite Suitelet SSv2如何使用對象填充多選對象
這裏是街市對象:
var marketplaces = {
amazonCom:{
label: 'Amazon.com',
searchId: 'customsearch_ca_export_detail_search__21',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_us'
},
amazonUK:{
label: 'Amazon.uk',
searchId: 'customsearch_ca_export_detail_search__33',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_uk'
},
amazonCA:{
label: 'Amazon.ca',
searchId: 'customsearch_ca_export_detail_search__23',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_ca'
},
amazonFR:{
label: 'Amazon.fr',
searchId: 'customsearch_ca_export_detail_search__26',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_fr'
},
amazonDE:{
label: 'Amazon.de',
searchId: 'customsearch_ca_export_detail_search__24',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_de'
},
amazonIT:{
label: 'Amazon.it',
searchId: 'customsearch_ca_export_detail_search__29',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_it'
},
amazonJP:{
label: 'Amazon.co.jp',
searchId: 'customsearch_ca_export_detail_search__30',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_jp'
},
amazonES:{
label: 'Amazon.es',
searchId: 'customsearch_ca_export_detail_search__37',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_es'
},
ebayCom:{
label: 'eBay.com',
searchId: 'customsearch_ca_export_detail_search__34',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_us2'
},
ebayUk:{
label: 'eBay.uk',
searchId: 'customsearch_ca_export_detail_search__51',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_uk2'
},
ebayAu:{
label: 'Amazon.au',
searchId: 'customsearch_ca_export_detail_search__50',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_au'
},
ebayVolt:{
label: 'eBay.com Volt',
searchId: 'customsearch_ca_export_detail_search__35',
scriptId: 'customscript_revant_ca_catalog_export',
deploymentId: 'customdeploy_revant_ca_catalog_volt'
}
};
我試圖按照文檔來填充多選場。這裏是代碼:
var marketplacesList = form.addField({
id:'selectedmarketplaces',
type:ui.FieldType.MULTISELECT,
label:'Marketplaces'
});
for (var i = 0; i<marketplaces.length; i++){
marketplacesList.addSelectOption({
value: marketplaces[i].label,
text: marketplaces[i].label
});
}
任何幫助嗎?
感謝,
- 傑西
謝謝!我仍然得到了JavaScript的處理(顯然)。謝謝你的提示。很高興這是一個簡單的修復。 – jdcaliff
小心使用for語句,您可以枚舉您不希望/期望的屬性。使用vanilla Javascript,你應該使用['Object.hasOwnProperty()'](http://brianflove.com/2013/09/05/javascripts-hasownproperty-method/)來確保你只訪問市場中定義的屬性目的。 (marketplaces.hasOwnProperty(marketPlace))// ...添加到列表中,否則繼續'我更喜歡使用具有[_.forOwn()](https:/ /lodash.com/docs/4.16.4#forOwn)(和許多其他偉大的助手) –