How to set value for multi-select field using netsuite suitescript 2.0?

I want to set a value for multi-select with existing values ​​in this field. (ie) If Filed has values ​​"A, B", then I want to add a new value "c" with existing values. Thus, the result will be "A, B, C".

I used the "N / Record" SubmitFields API modules to set the value for a Multi-select field, such as

CODE: SuiteScript 2.0 Version:

Source:

var strArrayValue = new Array(); strArrayValue [0] = "A"; strArrayValue [1] = "B"; strArrayValue [2] = "C"; record.submitFields({ type:'purchaseorder', id:56, values:{ custbody_multiselectfield: strArrayValue }, options: { enableSourcing: false, ignoreMandatoryFields : true } }); 

The error is displayed here: "you entered an invalid argument of type: arg 4"

Updated code:

  var strArrayValue = new Array(); strArrayValue [0] = "A"; strArrayValue [1] = "B"; strArrayValue [2] = "C"; var PORec = record.load({ // Loading Purchase Order Recod type:"purchaseorder", id:56, isDynamic: true )}; PORec.setValue('custbody_multiselectfield',strArrayValue ); // Setting Value (Array List) for Multi-Select Fields PORec.save(); // Saving Loaded Record 

It also shows an error: "Invalid custody_multiselectfield 31567,31568 link key"

But if I add the value as a string instead of a String Array, it will set only one value (ie), overriding the previous values. Example: Multi-select has only the value "C" instead of the values ​​"A, B, C".

Can anyone help in resolving this issue.

+8
javascript arrays multi-select netsuite suitescript
source share
1 answer

According to the NetSuite documentation, you cannot use this api method to edit or send field fields only to support inline editing (see SuiteAnswer ID: 45158). You may need to load a record using record.load (), change the values, and then send using record.save ().

EDIT: In response to an updated question, the only thing that seems impractical here is that you are trying to set the values ​​according to the displayed value of the field, where setValue () expects an internal identifier for the values. You can either change the values ​​you fill in with the corresponding internal identifiers, or change it to use the setText () method instead:

 var strArrayValue = new Array(); strArrayValue [0] = "A"; strArrayValue [1] = "B"; strArrayValue [2] = "C"; var PORec = record.load({ // Loading Purchase Order Recod type:"purchaseorder", id:56, isDynamic: true }); PORec.setText('custbody_multiselectfield',strArrayValue ); // Setting Value (Array List) for Multi-Select Fields PORec.save(); // Saving Loaded Record 

I tested both of these approaches, and both of them work for me.

+6
source share

All Articles