``` function lookUpCreditMemo(invoiceID) { var...
# suitescript
m
Copy code
function lookUpCreditMemo(invoiceID) {
    var creditmemoID = "";
    try {
      var srch = search.create({
        type: "creditmemo",
        filters: [
          ["createdfrom", "is", invoiceID],
          "AND",
          ["amountremaining", "greaterthan", 0],
          "AND",
          ["applied", "is", 0],
          "AND",
          ["custbody_edc_trans_type", "anyof", [2, 4]],
        ],
        columns: ["tranid"],
      });
      var searchResultCount = srch.runPaged().count;
      log.audit("search count", searchResultCount);
      if (searchResultCount > 0) {
        creditmemoID = srch.run().getRange(0, 1)[0].id;
      }
    } catch (e) {
      log.error({ title: "LookUp Credit Memo: " + invoiceID, details: e });
    }
    return creditmemoID;
  }
I have this search, which runs fine if I removed the filter on the
applied
field, but with it, it gives this error:
Copy code
An nlobjSearchFilter contains invalid search criteria: applied.
I can't figure out what is wrong with it
b
are you sure that
applied
is a filter?
m
What do you mean? Any field can be a filter, right?
b
no
m
What about custom fields?
because I have
custbody_edc_trans_type
there and it is working
I see in the record browser search filters https://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_1/script/record/creditmemo.html Didn't notice it before
b
The usual advice applies, make the search in the ui first then convert it to script
m
hmm, got it, thanks 🙏