最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to create a Search in SuiteScript 2.0 version - Stack Overflow

programmeradmin3浏览0评论

I want to create an search for the record using "SuitScript 2.0 version" . I know that i can achieve it using "SuiteScript 1.0" using nlapiSearchRecord() api using filters and conditions but i want do this with SuitScript 2.0 version. To this in "SuiteScript 2.0 " the "N/search Module" have to be used but not getting how to did the search in 2.0 in equivalent to suitscript 1.0 version.

Could any one give an example for the search in SuiteScript 2.0 version.

Thanks in Advance.

I want to create an search for the record using "SuitScript 2.0 version" . I know that i can achieve it using "SuiteScript 1.0" using nlapiSearchRecord() api using filters and conditions but i want do this with SuitScript 2.0 version. To this in "SuiteScript 2.0 " the "N/search Module" have to be used but not getting how to did the search in 2.0 in equivalent to suitscript 1.0 version.

Could any one give an example for the search in SuiteScript 2.0 version.

Thanks in Advance.

Share Improve this question edited Jul 14, 2016 at 6:19 Deepan Murugan asked Jul 14, 2016 at 5:01 Deepan MuruganDeepan Murugan 7713 gold badges22 silver badges42 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 14

You are correct that you will use N/search. It uses an analogous API to the 1.0 API of nlapiCreateSearch.

You will use search.create to build out your search object or search.load to load a saved search. Then you will invoke run on the resulting search object. Finally, you can process the results in two ways:

  1. Use the each method and a callback
  2. Use the getRange method to get a specific number of results

In the example below, I've imported N/search into my module as s and shown the usage of the each method.

function findCustomers() {
    // Create and run search
    s.create({
        "type": "customer",
        "filters": [
            ['isinactive', s.Operator.IS, 'F'], 'and',
            ['pany', s.Operator.NONEOF, ['123','456']
        ],
        "columns": ['email', 'firstname', 'lastname']
    }).run().each(processCustomer);
}

function processCustomer(result) {
    // do something with Customer search result
    // returns a boolean; true to continue iterating, false to stop
    return true;
}
发布评论

评论列表(0)

  1. 暂无评论