user7395254
user7395254

Reputation: 33

How do I use a sublist item on my netsuite 1.0 search filter? I tried doing an item.fieldname but it cause an error

I want to get a list or tranids of the custitem1 from items sublist that meet my criteria.

var filter = new Array();
filter[0] = new nlobjSearchFilter('mainline', null, 'is', 'T');
filter[1] = new nlobjSearchFilter('item.custitem1', null, 'is', 'myItems');  // this is not working
var column = new Array();
column[0] = new nlobjSearchColumn('tranid');
column[1] = new nlobjSearchColumn('createdfrom');
var fulFillSOInternalIDs = nlapiSearchRecord( 'itemfulfillment', null, filter, column);

Upvotes: 2

Views: 787

Answers (2)

vVinceth
vVinceth

Reputation: 915

you should join your filter. insert the filter below in @adolfos' code.

filter[1] = new nlobjSearchFilter('custitem1', 'item', 'is', 'myItems');

Upvotes: 1

Adolfo Garza
Adolfo Garza

Reputation: 3029

If your field doesn't support filtering with "anyof" then you will need to search using expressions. Also, if you are searching for the sublist values you need to have mainline as false cause mainline true only returns body fields. Here's how it works:

var columns = [];
columns.push(new nlobjSearchColumn("tranid"));
columns.push(new nlobjSearchColumn("createdfrom"));

var filters = [];
filters.push(["mainline", "is", "F"]);
filters.push("AND");
//PARENTHESIS START
//Looping through myItems array to create the expression
var parens = [];
for (var i in myItems){
    parens.push(["item.custitem1", "is", myItems[i]]);
    parens.push("OR");
}
parens.pop();//Remove the last OR
filters.push(parens);
//PARENTHESIS END

var transactionSearch = nlapiSearchRecord("itemfulfillment", null, filters, columns);

Upvotes: 1

Related Questions