im trying to set a multi select field value given ...
# suitescript
m
im trying to set a multi select field value given an array in a suitescript (user event) but i am not able to, I've tried several ways (array, text, text concatenated with \u0005) but was not able to.
l
can you send me what you already have
m
Copy code
truck.setValue({fieldId: 'custrecord_dt_sales_orders', value: [9538322, 59638311]});
@Livio
l
are those the internal ids of the values you want to set?
Copy code
var strArrayValue = new Array();
        strArrayValue [0] = "A";
        strArrayValue [1] = "B";
        strArrayValue [2] = "C";

   var myRec = record.load({              

                type:"purchaseorder",
                id:56,
                isDynamic: true

                 });

        myRec.setText('custbody_multiselectfield',strArrayValue );

        myRec.save();
Try this
m
i saw that, and tried it
let me retry
those are internal ids of sales orders
Copy code
let truck = nRecord.load({
                    type: 'customrecord1855',
                    id: transferId,
                    isDynamic: true
                });

                truck.setText({fieldId: 'custrecord_dt_sales_orders', value: ['Sales Order #SO106280']}); 
                truck.save();
and now I get an error saying that "Record has changed" on truck.save()
but if I do it like this:
Copy code
truck.setText('custrecord_dt_sales_orders', ['Sales Order #SO106280']);
I get
Copy code
"name":"INVALID_KEY_OR_REF","message":"Invalid custrecord_dt_sales_orders reference key Sales Order #SO106280."
Copy code
truck.setText('custrecord_dt_sales_orders', ['%SO106280']);
wildcards also not working
l
try this without saving the record. it should work
Copy code
var strArrayValue = new Array();
        strArrayValue [0] = 9538322;
        strArrayValue [1] = 59638311;

  truck.setValue('custrecord_dt_sales_orders',strArrayValue)
m
without saving it, it didnt throw an error but also it didnt update it
l
lets do one last thing. try loading and saving the record but change your UE script to after submit
m
i did that, and still not working 😞
Copy code
var strArrayValue = new Array();
        strArrayValue [0] = 9538322;
        strArrayValue [1] = 59638311;

  truck.setText({fieldId: 'custrecord_dt_sales_orders', value: ['Sales Order #SO106280']}); 

  truck.save();
it saves alright
so doesnt throw an error
l
replace sales order s0106280 with strArrayValue[0]
m
but still doesnt update the other record
it didnt work with setText
but it did with setValue!!
l
yeah my example was setValue
m
Copy code
let truck = nRecord.load({
                    type: 'customrecord1855',
                    id: transferId,
                    isDynamic: true
                });

  truck.setValue({fieldId: 'custrecord_dt_sales_orders', value: newRecord.getValue('custrecord_dt_sales_orders')}); 

  truck.save();
omg
thanks so much man!
l
you are welcome