Using Suitescript 2.0, how can I search records for sublist items with specific values

Viewed 696

I need a search that looks for line items with a specific value in a custom field - custcolunique_id

I am using the search below, but am getting a SSS_INVALID_SRCH_OPERATOR error due to custcolunique_id. That is definitely the internal field ID since I'm using it elsewhere in code without issue. Is there additional syntax needed in searches to specify that I want to look for a sublist item, or is there a different way entirely that I should be doing this?

var recordSearch = search.create({
            type: search.Type.PURCHASE_ORDER,
            columns: ['custcolunique_id'],
            filters: [['mainline', 'is', 'F'],
                'and', ['custcolunique_id', 'is', '123']]
        });
1 Answers

You have the correct approach, but the error is telling you that your Operator ('is') is not valid for your field type. You need to use an Operator that is valid for custcolunique_id's field type. 'is' is only valid for text fields and checkboxes.

You can see valid Operators by field type in Help:SuiteScript 1.0 Search Operators. Despite the page title, the content is applicable to 2.0 as well.

Related