Uma Kanth
Uma Kanth

Reputation: 5629

What is the internal id(name/number) for a saved search record type?

I created a savedSearch for a savedSearch itself via UI with an internal id customsearch_savedsearch.

When I'm loading the search using a suiteScript. It shows me an Unexpected error has occured.

var search = nlapiLoadSearch(null, 'customsearch_savedsearch');

The above statement works fine for all other record-types, But fails for a savedSearch record type.

What could be the internal id for the savedSearch record type?

Upvotes: 0

Views: 3423

Answers (7)

Michael McCauley
Michael McCauley

Reputation: 933

I know this is a bit of an old question, and I came across it in my own attempt to do the same, but I just tried the following with success:

var search = nlapiLoadSearch('savedsearch', 'customsearch_savedsearch');

Seemed a little on the nose, but it did the trick.

Upvotes: 0

Leibnitz Jacquard
Leibnitz Jacquard

Reputation: 469

Your syntax is correct. However, Saved Search type (also like Budget record) is not scriptable even you are able to create a saved search. That is why you encountered that error. Most likely, those record types listed on the SuiteScript Record Browser are supported. You may check the list here:

***Note: You should log in first to the account..
Production: https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_1/script/record/account.html

Sandbox: https://system.sandbox.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_1/script/record/account.html

Upvotes: 0

Binoy Samuel
Binoy Samuel

Reputation: 144

You should be able to run this using the above mentioned

var search = nlapiSearchRecord(null, 'customsearch_savedsearch',null,null); 

I've used this in my code and haven't had any issues. Make sure you have the right permissions set on the saved search. To start with, set it as Public. And in the Audience, "select all" roles.

Upvotes: 0

user3075978
user3075978

Reputation: 845

Everything looks correct in your statement. I think the problem is that SuiteScript does not support SavedSearch record types. Here is a list of supported types.

Upvotes: 0

Rusty Shackles
Rusty Shackles

Reputation: 2840

If `

var search = nlapiSearchRecord(null, 'customsearch_savedsearch'); 

does not work`use

var search = nlapiSearchRecord('', 'customsearch_savedsearch');

Upvotes: 0

lavb
lavb

Reputation: 628

Try

var search = nlapiSearchRecord(null, 'customsearch_savedsearch');

Documentation:

nlapiSearchRecord(type, id, filters, columns)

Performs a search using a set of criteria (your search filters) and columns (the results). Alternatively, you can use this API to execute an existing saved search. Results are limited to 1000 rows. Also note that in search/lookup operations, long text fields are truncated at 4,000 characters. Usage metering allowed for nlapiSearchRecord is 10 units.

This API is supported in client, user event, scheduled, portlet, and Suitelet scripts.

Upvotes: 0

erictgrubaugh
erictgrubaugh

Reputation: 8847

You cannot use null for the first parameter. When loading or creating a search, you must specify the record type for the search as well. Whatever record type customsearch_savedsearch searches for, that's what you would pass in as the first parameter.

So for instance if your saved search is a Customer search, then you would load it by:

var search = nlapiLoadSearch('customer', 'customsearch_savedsearch');

Upvotes: 1

Related Questions