Sales Campaign
The sales campaign record helps you refine the sales campaign for a marketing campaign.
For help working with this record in the UI, see Sales Campaigns.
The internal ID for this record is salescampaign.
This record contains the following subrecords:
-
audience
-
category
-
family
-
offer
-
owner
-
ownerRole
-
promotionCode
-
searchEngine
-
vertical
This record contains the following sublists:
-
campaignDirectMail
-
campaignDrip
-
campaignEmail
-
campaignEvent
-
defaultEvent
For information about using the SuiteScript Records Browser, see Working with the SuiteScript Records Browser in the NetSuite Help Center.
Supported Script Types
The sales campaign record is scriptable in both client and server SuiteScript.
Supported Functions
The sales campaign record is fully scriptable - it can be created, updated, copied, deleted, and searched using SuiteScript. The transform function isn't supported.
Prerequisites
You must enable the Marketing Automation and Sales Campaigns features before you can use this record with SuiteScript. For more information, see Marketing Automation Overview and Sales Campaigns.
To use all the fields on this record, you must enable the following features: Promotion Codes, Subscription Categories, and Mail Merge.
Additional Details
-
The following fields in the Statistics tab are read-only and automatically computed with REST services: totalRevenue, roi, profit, costPerCustomer, convCostPerCustomer, conversions, leadsGenerated, uniqueVisitors.
-
The cost field is automatically computed based on costs for associated events.
-
The campaignId field is read-only and generated after the record is created.
-
The defaultEvent sublist is read-only and generated after the record is created.
Code Samples
The following samples show common actions with sales campaign scripting.
Create script example:
var record = nlapiCreateRecord('salescampaign', true);
record.setFieldValue('title', 'Test sales title');
record.setFieldValue('owner', '-5');
record.setFieldValue('startdate', '2025-10-13');
…
record.setNewLineItem('campaigndrip');
record.setCurrentLineItemValue('campaigndrip', 'channel', '-7');
record.setCurrentLineItemValue('campaigndrip', 'cost', '1.00');
record.setCurrentLineItemValue('campaigndrip', 'description', 'Campaign drip description');
record.setCurrentLineItemText('campaigndrip', 'promocode', '20% On Everything');
record.setCurrentLineItemValue('campaigndrip', 'subscription', '2');
record.setCurrentLineItemValue('campaigndrip', 'template', '2');
record.commitLineItem('campaigndrip');
…
var recordId = nlapiSubmitRecord(record);
Update script example:
record = nlapiLoadRecord('salescampaign', recordId);
record.setFieldValue('title', 'Test title updated');
...
record.removeLineItem('campaigndrip', 1);
record.selectNewLineItem('campaigndrip');
record.setCurrentLineItemValue('campaigndrip', 'channel', '-7');
record.setCurrentLineItemValue('campaigndrip', 'cost', '5.00');
record.setCurrentLineItemValue('campaigndrip', 'description', 'Campaign drip new description');
record.setCurrentLineItemValue('campaigndrip', 'promocode', '2');
record.setCurrentLineItemText('campaigndrip', 'subscription', 'Surveys');
record.setCurrentLineItemValue('campaigndrip', 'template', '28');
record.commitLineItem('campaigndrip'):
…
recordId = nlapiSubmitRecord(record);
Delete script request:
nlapiDeleteRecord('salescampaign', recordId);