prasun
prasun

Reputation: 7343

SuiteScript 2.0 search.Type is undefined

I am trying something like below:

require(['N/search'],
    function(search)
    {
            var mySearch = search.create({
                type : search.Type.FOLDER,
                columns : ['internalid'],
                filters : [ 'internalid', 'anyof', ID]
            });
            mySearch.run();
    });

I get an error for search.Type.FOLDER that search.Type is undefined and so cannot find FOLDER of undefined

I was able to do a workaround by writing a type as 'folder' that worked, but, why is this enum not defined if it is documented in NetSuite's help.

I tried even logging all keys using Object.keys and the returned array does not contains Type key.

Has anyone tried this or if anyone can point out if something is wrong with my code?

Upvotes: 1

Views: 1896

Answers (1)

erictgrubaugh
erictgrubaugh

Reputation: 8902

I don't see anything wrong with your code, and I confirmed in my own instance that the module brought in by N/search does not include a Type enum. Including the N/record module does have correctly have the Type enum, so if you want to avoid the magic string 'folder', you could import N/record and use record.Type.FOLDER instead.

It's not ideal, as what you are doing should work, but it seems there must be a bug in the search module where they're not properly returning the Type enum.

Upvotes: 3

Related Questions