Netsuite search filter in script

Viewed 130

I have a workflow action script with a variable 'assembly', which contains the internal ID of an item (type is always assembly). Now I want to search for bills of materials for this item. However, my search returns 'An nlobjSearchFilter contains invalid search criteria: id.' Trying 'internalid' does not work either. If anyone can help that would be great.

    var filters = new Array();
            filters[filters.length] = new nlobjSearchFilter('internalid', 'assemblyitem', 'is', assembly);

    var columns = new Array();
    columns[columns.length] = new nlobjSearchColumn('internalid');

    var searchResults = nlapiSearchRecord('bom', null, filters, columns);

    var internalId = searchResults[1].getId();
    var bom = searchResults[1].getValue('internalid');
1 Answers

Have you confirmed that the value of variable assembly is a valid assembly item internal id?

Also sometimes, though maybe only in the past, I've had issues with internal id searches where the scalar test doesn't work but the following does:

var filters = [
    new nlobjSearchFilter('internalid', 'assemblyitem', 'anyof', [assembly])
];

Also the other thing to try (even though the data dictionary doesn't list it) would be:

var filters = [
    new nlobjSearchFilter('assemblyitem', null, 'anyof', [assembly])
];
Related