I think I'm going crazy. ```require(['N/record','N...
# suitescript
s
I think I'm going crazy.
Copy code
require(['N/record','N/runtime','N/search','N/format'], function(record,runtime,search,format) {
  try{
    const recordType = record.Type.CASH_SALE; //'cashsale'
    const recordType2 = search.Type.CASH_SALE;//'cashsale'
    const recordType3 = "CashSale"

    var transactionSearchObj = search.create({
      type: "transaction",
      filters: [
        ["type", "anyof", recordType3],
        "AND",
        ["mainline", "is", "T"],
      ],
      columns: [search.createColumn({name: "internalid", label: "Internal ID"})],
    });
    var searchResultCount = transactionSearchObj.runPaged().count;
    //log.debug("transactionSearchObj result count", searchResultCount);
/*
    transactionSearchObj.run().each(function(result) {
      matched = true;
      recId = result.id;
      return false;
    });
*/
  var abc = 1;

  } catch (e) {
    var scriptId = runtime.getCurrentScript().id;
    log.error('ERROR:'+scriptId+':fn:'+runtime.executionContext, JSON.stringify({type: e.type,name: e.name,message: e.message,stack: e.stack,cause: JSON.stringify(e.cause),id: e.id}));
  }
});
why would the search enum not equal "CashSale" ??? And why doesn't the search work with the enum???
c
type: "transaction",
?
s
?? recordType==recordType2 ?? recordType3!=recordType
c
You want `
Copy code
var transactionSearchObj = search.create({
      type: search.Type.CASH_SALE,
`
Or I've completely misunderstood.
TBH, use SuiteQL
💯 1
s
@CD will try suiteql, was hoping to do a transaction search that could have multiple record types. so was looking at transaction as a search type instead...
s
'transaction' as the searchType is perfectly fine/valid... the values of the enums are generally not the same and they are also not generally what you would put in search filters. You aren't going crazy and I don't think there is an enum for what you are wanting to do
s
Sandii is correct - the
search.Type
enum only applies to the
type
property when creating the search. It doesn't apply to filter values.
✅ 2
m
Install Netsuite Toolbox browser extension. Then create the search you want in the interface and use Netsuite Toolbox Export Search to JSON. Then you will see all the necessary enums that you will need. When you are using the
anyof
operator you want to pass the values as an array. Like this:
Copy code
["type", "anyof", ["cashsale", "salesorder"]]