gpt4 book ai didi

javascript - NetSuite Suitelet SSv2 如何使用对象填充多选

转载 作者:行者123 更新时间:2023-12-03 05:35:59 26 4
gpt4 key购买 nike

我试图简单地用市场列表填充多选字段。

这是市场对象:

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

});

}

有什么帮助吗?

谢谢

  • 杰西

最佳答案

您的问题是 marketplaces 不是数组,因此它没有 length 属性。

尝试将 for 行替换为:

for (var i in marketplaces) {
if(!marketplaces.hasOwnProperty(i)) {
continue;
}

// Add option for form or whatever...
}

关于javascript - NetSuite Suitelet SSv2 如何使用对象填充多选,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40731586/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com