marshal is not a function
So there you were, writing yet another script that was meant to keep your company in business when shit hit the fan.
All of a sudden NetSuite decided to thwart your efforts only to inform you that Marshall Elem is not functioning. Who or what is Marshall Elem? Why is he not working? Should you even care?
There are two answers to your question.
If you are situated near Tulsa, Oklahoma, NetSuite may be trying to warn you that Marshall Elementary School is going out of business. If your children are attending this institution - I suggest you don't take that lightly.
If you don't have kids, or at least not near Oklahoma and therefore safe, I can actually help you.
TypeError: elem._marshal is not a function usually happens when you are trying to filter a saved search and you use wrong datatype in the filters - specifically when search expected string or integer value and you have provided an object.
Pictured: Marshall not functioning, having unlimited fun.Typical scenario:
You are obtaining a field value from a select field using search.lookupFields() method.
let entityId = search.lookupFields({
type: 'invoice',
id: '666',
columns: ['entity']
});
Perhaps you would like to use the entityId in your search, one that may look like this:
let txSearch = search.create({
type: 'transaction',
filters: ['entity', 'anyof', entityId],
columns: [colInternalId, colDate],
});
You may expect the search.lookupFields() to return the internal id of the entity field, but since entity is a selection field that contains both internal id and text, it will return an object instead:
{
entity: [
{
text: 'customer XY',
value: 333
}
]
}
Chances are you are only interested in the value, which represents the internal id of your selection, because that's what you plan on using in your search filters. But instead you would be pushing this entire object into your filter and that's when you are greeted by Marshall Elem.
Easy fix:
let entityId = search.lookupFields({
type: 'invoice',
id: '666',
columns: ['entity']
}).entity[0].value;
By appending the .entity[0].value you will receive the value of the first element in the resulting array - in this example 333 - which will be happily accepted by your saved search.