Campaign Template
The campaign template record is used for both CRMSDK templates and scriptable templates. In the UI, you find this record by choosing Documents > Templates > Marketing Templates.
For help working with this record in the UI, see Email Marketing Campaigns.
Scriptable templates are not supported with SuiteScript.
The internal ID for this record is campaigntemplate
.
See the SuiteScript Records Browser for the internal IDs of all fields associated with this record, their corresponding labels in the UI, and more details. Fields not listed in the Records Browser are not supported and should not be used.
For information about using the SuiteScript Records Browser, see Working with the SuiteScript Records Browser.
For information about scripting with this record in SuiteScript, see the following:
Supported Script Types
The campaign template record is scriptable in server SuiteScript only.
All three user events are supported: beforeLoad
, beforeSubmit
, and afterSubmit
.
Field Definitions
This section describes some of the key fields on the campaign template record.
Content and Mediaitem
When accessing this record, only one of the following fields contains a value:
-
content — This field maps to the text editor that appears on the Template tab in the UI. This field contains plain text or HTML.
-
mediaitem — This field maps to the File text box that appears on the Template tab in the UI. This field identifies the file that is used as the basis for the template.
Code Sample
The following sample shows how to access template content:
var template = record.load({
type: record.Type.CAMPAIGN_TEMPLATE,
id: 154
});
if (template.getValue({fieldId: 'mediaitem'}) != null) {
var media = template.getValue({fieldId: 'mediaitem'});
// do something with the media...
} else {
var content = template.getValue({fieldId: 'content'});
// do something with the content...
}