Prabhu
Prabhu

Reputation: 927

How to search customer type records alone in Netsuite Suitescript 2.0

I can search customer records using below script. This was working fine.

require(['N/search'])
search = require('N/search')
var options = {
    type: "customer"
};
options.columns = ["companyname", "firstname", "middlename", "lastname"];

var customerSearch = search.create(options);

var results = customerSearch.run({
}).getRange({
    start: 0,
    end: 5
});

log.debug(results)

I get result as list of customer, lead, prospect & job.

Why I get lead, prospect & job records while searching customer?

How to get customer type records alone while searching?

Upvotes: 0

Views: 1106

Answers (1)

bknights
bknights

Reputation: 15462

You get this because all of those are 'stages' of the customer process.

You need to add a filter:

options.filters = [['stage', 'anyof', ['CUSTOMER']]];

Upvotes: 3

Related Questions