Reputation: 1022
I have some custom script populating a sublist with all vendor item prices for a given vendor.
I haven't been able to locate the correct field id for the "preferred vendor" flag.
My current search params at present are as follows:
var filters = new Array();
var columns = new Array();
filters[0] = new nlobjSearchFilter('vendorcost', null, 'greaterthan', 0);
filters[1] = new nlobjSearchFilter('internalid', 'vendor', 'anyof', vendorid );
columns[0] = new nlobjSearchColumn('itemid');
columns[1] = new nlobjSearchColumn('entityid', 'vendor');
columns[2] = new nlobjSearchColumn('vendorcost');
columns[3] = new nlobjSearchColumn('vendorcode');
columns[4] = new nlobjSearchColumn('vendorpricecurrency');
columns[5] = new nlobjSearchColumn('preferredvendor');
var searchresults = nlapiSearchRecord('item', null, filters, columns );
Unfortunately, column 5 is failing. I've tried 'preferredvendor' with and without a join to 'itemvendor' but without success.
Any help would be appreciated.
Upvotes: 1
Views: 935
Reputation: 7343
preferredvendor
is not a valid searchColumn.
If you are using Multiple Vendors
feature and you want to search all vendor lines on items along with details that which one is preferred I suggest to use vendor
and othervendor
as searchcolumns.
vendor
will have only preferredvendor
and othervendor
will have both preferred and normal vendors.
You can use a condition to distinguish Preferred vendors from others using
if(searchResults[i].getValue('vendor') === searchResults[i].getValue('othervendor')){
//this is your preferred vendor search result, and not normal vendor line
}
Also, I suggest you to use othervendor
as filter over vendor
, if you want to get all vendors(preferred and non-preferred both) in the search results
i.e. Instead of
filters[1] = new nlobjSearchFilter('internalid', 'vendor', 'anyof', vendorid );
use
filters[1] = new nlobjSearchFilter('othervendor', null , 'anyof', vendorid );
FYI, there is a filter ispreferredvendor
but, unfortunately it is not included in search column. But, vendor
search column as stated above fulfils that requirement
Upvotes: 1