Netsuite Tricks: elem._marshal error in netsuite

Hi All ,

In this post , we are going to write about an error which is not explained properly by Netsuite.
When you use search.Create (or load) and write filter for Select/Multiselect fields or internal id,
you might see this error.

TypeError: elem._marshal is not a function

Reason:
 This happen when you add object in place of single value in filter ex: for list/record enter object not value.

example:
If you write code like these where "serviceType" variable has value as object (not  single value)
var mdetails = search.lookupFields({
                                                type: search.Type.EMPLOYEE,
                                                id: customer,
                                                columns: ['custentity_FieldId']
                                            });
                            var serviceType= jobDetails.custentity_FieldId;// here value returned is object
                            if(serviceType)
                            {
                                serviceType = serviceType[0].value; //error will come if we don't use this.
var myCSearch = search.create({
                                                    type: 'customrecord_customrecordid',
                                                    title: null,
                                                    id: null,
                                                    columns: [{
                                                                name: 'internalid'
                                                            }],
                                                    filters: [
                                                        ['custrecord_listtype', 'anyof', [serviceType]],
                                                      ]
                                                });
                                    
}

We hope this will help many people. Lets us know if you face any issue.

Thanks
Netsuite Guru
Download Netsuite Guru Android App
Follow Me on Linkedin
Our FB Page

Comments