Netsuite Suitelet SSv1将多重选择值更改为数组

时间:2016-12-20 17:16:33

标签: javascript netsuite

我的kitlet的GET部分有一个多选字段,我试图在POST部分使用该字段的值。

这是GET部分中的多选字段,因为它由对象填充:

var marketplacesList = form.addField('selectedmarketplaces','multiselect','Marketplaces',null,'part3');

    for (var k in marketplaces){

        marketplacesList.addSelectOption(k,marketplaces[k].label);

    }

然后当我在POST部分中记录值时:

    var selectedMarkets = request.getParameter('selectedmarketplaces'); //gets a multiselect from GET section

    nlapiLogExecution('DEBUG','selectedMarkets',selectedMarkets);

我收到以下字符串:

" amazonComamazonUKamazonCAamazonFRamazonDEamazonITamazonJPamazonESebayComebayUkebayAuebayVolt"

如何将multiselect的值设为数组,以便将其用于迭代等?

谢谢,

  • 杰西

2 个答案:

答案 0 :(得分:2)

这样做:

var selectedMarkets = request.getParameter('selectedmarketplaces'); //gets a multiselect from GET section
selectedMarketsArray   = selectedMarkets.split("\u0005"); //Turns it into an array
nlapiLogExecution('DEBUG','selectedMarketsArray',JSON.stringify(selectedMarketsArray));

答案 1 :(得分:1)

对于Netsuite 2.0

var perams = context.request.parameters.selectedmarketplaces.split("\u0005") //Turns it into an array
log.debug('perms', perams)