Sanity check on a saved search. If I create a sear...
# suitescript
r
Sanity check on a saved search. If I create a search with the following filters
Copy code
filters: [["mainline","is","T"],"AND",["custbody_uv_installation_site","anyof",6942]]
I get 3 results (expected),
internalid
&
type
as columns.
Copy code
[{"internalid":{"value":345847},"type":{"value":"Estimate"}},{"internalid":{"value":348608},"type":{"value":"Estimate"}},{"internalid":{"value":348610},"type":{"value":"Estimate"}}]
however, if I run the same search with the addition of a filter for
type
(using
search.Type.ESTIMATE
as the typeof string)
Copy code
filters: [["type","anyof",["estimate"]],"AND",["mainline","is","T"],"AND",["custbody_uv_installation_site","anyof",6942]]
I get 0 results. What am I missing?
a
search.Type.ESTIMATE is for a search type... not a search filter of transaction type
👍 1
search.create({ type: serach.Type.ESTIMATE >> 'estimate' this is fine. but as a filter its actually "Estimate"
r
what enum should I be using if I want to filter by a particular transaction type then?
c
You can do a search.Type.TRANSACTION and then check the type field for transaction types you want. Would need to check what type is coming back and then you can filter by that. Transactions have weird IDs like WorkOrd sometimes.
r
oh, it's that list. gothca.
c
If you want specific transactions, you can do the search.Type.TRANSACTION from search.Type like Anthony mentioned.
r
my end goal is I need to find all transactions of type Estimate or Opportunity, which is why I did a
search.Type.TRANSACTION
. I didn't know that when using as filters, you couldn't use the same type enum
thanks for the answers. One more quirk noted for future reference!
c
You would need an OR clause like:
Copy code
[
    [type is estimate],
    "OR"
    [type is opportunity]
]
a
ngl I likely would have done the exact same thing
r
yea, I had that part already. just didn't have the right strings to search for
🍻 1
c
opprtnty / estimate are the IDs. They may be the same as record.Type.ESTIMATE/record.Type.OPPORTUNITY but its been a minute since i've checked it out.
r
just tried both
search.Type.OPPORTUNITY
and
record.Type.OPPORTUNITY
. Both are the string
opportunity
. I remember finding a website that had the IDs, and made my own enum 'cause I couldn't find a native module that had an appropriate enum.
n
Try filters like this:
Copy code
filters:
   [
      ["type","anyof","Estimate"], 
      "AND", 
      ["mainline","is","T"]
   ]
and see what happens.