0
votes

I have a SuiteScript 2.0 that load and search transaction saved search with posting period filter. In my filter I am using 'anyof' operator which is not working for 'postingperiod' field

below is sample of my code:

function getTransactionData(datain)
{
    try
    {

        var objSearch = search.load(
        {
            id: datain.savedsearchid
        });

        objSearch.filters.push(search.createFilter({ name: "postingperiod",  operator: "ANYOF", values: ["42", "43"]}));
    //above filter filters only record with internalid 42 
        result = readAllData(objSearch);
        return result;
    }
    catch (ex)
    {
        log.error("getTransactionData", ex);
        throw ex;
    }
}

let me know if I am missing something here.

Please note above issue is occurring only for saved search, if I search other object for example 'account' object with internalid filter using 'anyof' operator, works fine.

Update: Today after more testing, found that its only happening for 'postingperiod' filter.

1
can anybody suggest me a solution for this? - umesh shukla
Would you be able to post the code that is working for the account object? - jordanw
Here is code where 'AnyOf' operator is work fine for account search: - umesh shukla
function getDimensionData() { var objSearch = search.create ({ type: search.Type.ACCOUNT, filters: [], columns: ["internalid","name"] }); //below filter works fine with 'anyof' operator and returns accounts with internalid 1 and 2 objSearch.filters.push(search.createFilter({ name: "internalid", operator: "ANYOF", values: ["1", "2"]})); return readAllData(objSearch); } - umesh shukla

1 Answers

0
votes

Try this code in Netsuite Debugger, Create a SavedSearch in Netsuite, don't add any filter in that , save that and get the id of saved search and use in below script against id value. Also replace the Period Id with yours.

require(['N/runtime','N/search'],
    function (runtime,search) {
    var invoiceSearchObj = search.load({
       type: "invoice",
       id: '<your search id>',

       columns:
       [
          search.createColumn({
             name: "trandate",
             sort: search.Sort.ASC,
             label: "Date"
          })
       ]
    });


    invoiceSearchObj.filters.push(search.createFilter({ name: "postingperiod",  operator: "ANYOF", values: ["<your period value>"]}));
    invoiceSearchObj.filters.push(search.createFilter({ name: "mainline",  operator: "is", values : "T"}));


var searchResultCount = invoiceSearchObj.runPaged().count;
log.debug("invoiceSearchObj result count",searchResultCount);
invoiceSearchObj.run().each(function(result){
   // .run().each has a limit of 4,000 results
   return true;
});

});
var a=0;