I want to set the value for the multi-select with existing values in that field. (i.e) If the Filed has the values "A , B" means I wants add the New Value "c" with Existing Values So, Result would be "A,B,C" .
I used "N/Record' Modules SubmitFields API to set the value for the Multi-select Field like this
CODE : SuiteScript 2.0 version :
Initial Code:
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
}
});
It is showing the error like this : "you have entered an Invalid Type Argument :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 is also showing the error: " Invalid custbody_multiselectfield'reference key 31567,31568 "
But if I add an Value as an String instead of String Array it is setting only single value (i.e) overriding the previous values. Ex: Multi-select has only the "C" value instead of "A,B,C" Values.
Can anyone help regarding this question.
I want to set the value for the multi-select with existing values in that field. (i.e) If the Filed has the values "A , B" means I wants add the New Value "c" with Existing Values So, Result would be "A,B,C" .
I used "N/Record' Modules SubmitFields API to set the value for the Multi-select Field like this
CODE : SuiteScript 2.0 version :
Initial Code:
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
}
});
It is showing the error like this : "you have entered an Invalid Type Argument :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 is also showing the error: " Invalid custbody_multiselectfield'reference key 31567,31568 "
But if I add an Value as an String instead of String Array it is setting only single value (i.e) overriding the previous values. Ex: Multi-select has only the "C" value instead of "A,B,C" Values.
Can anyone help regarding this question.
Share Improve this question edited Apr 25, 2017 at 11:58 Deepan Murugan asked Apr 23, 2017 at 6:48 Deepan MuruganDeepan Murugan 7713 gold badges22 silver badges42 bronze badges3 Answers
Reset to default 12According to NetSuite's documentation, you cannot use this api method to edit or submit select fields - only fields that support inline editing (see SuiteAnswer ID:45158). You may have to load the record with record.load(), modify the values and then submit with record.save().
EDIT: In answer to the updated question, the only thing that appears amiss here is that you are trying to set the values by the display value of the field, where setValue() is expecting the Internal ID of the values. You can either change the values you're populating with the relevant internal IDs, or you could 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 these approaches and both work for me.
If using a client script setting multiselect values is simple. In my case I was searching for subordinates of an employee. For each result I push the internalid
of the subordinate (employee record) to an array. Then on my multiselect field of type 'Employee' I set the values like below:
var subordinates = [];
// do search and push internalids of employees
currentRecord.setValue({
fieldId: 'custrecord_emp_subordinates',
value: subordinates
});
Hopefully this helps someone!
If you are loading the record everytime you want to update the multi-select field value, you can fetch the data in the field and store it in a variable.
var multiSelectData = record.getValue({
fieldId:''
});
The data will be in the form of an array, so you can push your data in the array.
multiSelectData.push(yourData);
Finally, you can submit the this variable and save the record.
record.setValue({
fieldId:'',
value: multiSelectData
});
Note - Please take care of the datatypes. Typecast if required.