Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 332
Deepan Murugan Avatar asked Apr 23 '17 06:04

Deepan Murugan


1 Answers

According 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.

like image 83
Krypton Avatar answered Sep 19 '22 12:09

Krypton