SuiteScript Joined Searches – Search Filters Table

When I completely OCD out on a problem and finally get an answer, I want two things. First, I don’t ever want to waste time on it again. And second, I don’t want anyone else wasting time on it either. If you ever need to write a search in SuiteScript that involves a join, please read this first!

I needed a popup that would search through a custom record type based on various filters.

Popup

So the code under the hood required the following (not that this really matters, It’s just for the curious).

  • An inline HTML button to launch this popup.
  • A client script to fetch the HTML from a file in the file cabinet to render this page.
  • A Restlet that gets called when the user clicks search to deliver the results.

So now I’m only going to focus on the Restlet that delivers the results in this popup. And I’m going to give you the basics of how I coded my filter for two of the fields on the screen, owner and vendor. They don’t work the same, and dang was this frustrating.

Here are the definitions for owner and vendor in my Software Agreements custom record type.

Software Agreements Definition

Notice, both are List/Record types. However, they reference different lists. This was the rub! You’d expect them to work the same, but they DID NOT. 

I kept getting an error on the search filter definition at the time the search executed. It was telling me I had an invalid search expression. When I omitted the vendor criteria, it worked. When I added back the vendor criteria, it failed. Here’s the code after it was working.

4-11-2019 2-42-49 PM

Here’s the dirty little secret. There’s this thing called the record type’s Valid Search Filters table. What the heck? companyname is in this table for customers, but not in it for vendors. In order to search for companyname in the vendor’s table, I needed to swap companyname for entityid.

I worked with a wonderful support rep from NetSuite name Fe. I asked her, “How can I prevent this from happening again?” Here is what she told me.

To make sure that all search filter IDs are valid:

  1.     Open the SuiteScript Records Browser(SuiteAnswers ID: 74610 – The SuiteScript Records Browser).
  2.     Navigate to the record type being searched.
    1. kindly go to Vendor
  3.     Locate the Search Filters table and check if all nlobjSearchFilter field IDs used in your code are found within the table. 

You can also refer to SuiteAnswers ID: 45294 – SuiteScript Error SSS_INVALID_SRCH_FILTER

Hopefully, this saves you the headache I have right now after resolving this issue. And many thanks to Fe for her excellent help.

Happy coding!

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s