Hi All, trying to set values to a multiselect in S...
# suitescript
g
Hi All, trying to set values to a multiselect in SS 2.0, there are times that it ok, bbt there is an instance that an error is being thrown
Copy code
var recData = {
                custrecord_fb_ed_from_item : arrMatrixItems,
                custrecord_fb_ed_customer : recipient,
                custrecord_fb_ed_date_sent : currDate,
                custrecord_fb_ed_sentby : currentUser,
                custrecord_fb_ed_project : project,
                custrecord_fb_ed_docs : arrDocInfo.join('<br/>'),
                custrecord_fb_ed_msg : request.parameters.message,
                custrecord3 : ccrecipient
            };

for ( var key in recData) {
                if (recData.hasOwnProperty(key)) {
                    objRec.setValue({
                        fieldId : key,
                        value : recData[key]
                    });
                }
            }

            var id = objRec.save({
                enableSourcing : false,
                ignoreMandatoryFields : false
            });
arrMatrixItems is an array =
["43546","41957","40175","40174"]
and the error thrown is:
{"type":"error.SuiteScriptError","name":"INVALID_FLD_VALUE","message":"You have entered an Invalid Field Value 43546\u000541957\u000540175\u000540174 for the following field: custrecord_fb_ed_from_item","stack":["anonymous(N/serverRecordService)"
please note that this works on other instance. For some reason 'arrMatrixItems' is reading it with delimiter '\u0005' rather as an array
b
multiple select fields can be set with an array of string internal ids or the less well documented string joined by \u0005
try checking if the select options represented by "43546","41957","40175","40174" are valid options
g
@battk they are valid values. most of the cases, it worked. not sure why it's not working on this instance
i set it manually via the UI and they seemed to be valid
arrMatrixItems = ["43546","41957","40175","40174"]
Copy code
arrMatrixItems isArray: true
arrMatrixItems typeof: object
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "INVALID_FLD_VALUE",
  "message": "You have entered an Invalid Field Value 43546\u000541957\u000540175\u000540174 for the following field: custrecord_fb_ed_from_item",
  "stack": [
    "anonymous(N/serverRecordService)",
    "onRequest(/SuiteScripts/devg scripts/fb_sl_custom_item_email.js:330)"
  ],
  "cause": {
    "type": "internal error",
    "code": "INVALID_FLD_VALUE",
    "details": "You have entered an Invalid Field Value 43546\u000541957\u000540175\u000540174 for the following field: custrecord_fb_ed_from_item",
    "userEvent": null,
    "stackTrace": [
      "anonymous(N/serverRecordService)",
      "onRequest(/SuiteScripts/devg scripts/fb_sl_custom_item_email.js:330)"
    ],
    "notifyOff": false
  },
  "id": "",
  "notifyOff": false,
  "userFacing": false
}
b
you can try loading the record in dynamic mode, get the field, and then log its select options to validate that those values are valid choices