1
votes

I am trying to create a search in SuiteScript 2.0 to find email templates on a NetSuite account. I can create the search on the NetSuite UI, but this record type(emailtemplate) is not supported by the "NetSuite: Search Export" Chrome plugin.

My JavaScript Search currently looks as follows:

var templates = search.create({
            type: "emailtemplate",
            filters:
               [

               ],
               columns:
               [
                search.createColumn({
                    name: "entityid",
                    sort: search.Sort.ASC
                 }),
               ]
        }).run().each(function(result){              
              //additional code
            return true;
        });

According to the NetSuite Schema Browser, "emailtemplate" is the correct record type - this however does not seem to be recognized by NetSuite.

I receive the following error when running my code: NetSuite Error

I assume that the schema browser and actual record name differs. Any help or guidance on this would be much appreciated.

2

2 Answers

0
votes

According to SuiteAnswers Article 10242, the emailtemplate type is not supported for searches in SuiteScript. It is scriptable with other SuiteScript modules like N/record.

0
votes

What is the context and what are you trying to do? If you have a form involved you can create a list/record email template field and let your user select from the list.

If you are configuring a script you can create a list/record email template parameter field.

These handle most use cases.

If your script context is a Suitelet or UserEvent script then you can create or access a form object and add a list/record email template field and use Field.getSelectOptions(options) to return a list of email templates with their names and ids. Check the sample code on that topic in the Netsuite help