简体   繁体   中英

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?

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

You need to add a filter:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM