email.sendCampaignEvent.promise(options)

Method Description

Sends a single “on-demand” campaign email asynchronously to a specified recipient and return a campaign response ID to track the email. This is used for lead nurturing campaigns (drip marketing email). If the email fails to send, the value returned is –1.

Note:

The parameters and errors thrown for this method are the same as those for email.sendCampaignEvent(options). For more information about promises, see Promise Object.

Returns

Promise Object

Synchronous Version

email.sendCampaignEvent(options)

Supported Script Types

Client scripts

For additional information, see SuiteScript 2.x Script Types.

Governance

10 units

Module

N/email Module

Since

2015.2

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete promise script example, see Promise Object.

          // Add additional code 
...
// Create a campaign record in dynamic mode so all field values can be dynamically sourced.
var campaign1 = record.create({
    type: record.Type.CAMPAIGN,
    isDynamic: true
});
campaign1.setValue({
    fieldId: 'title',
    value: 'Sample Lead Nurturing Campaign'
});
// set values on the Lead Nurturing (campaigndrip) sublist
campaign1.selectNewLine({
    sublistId: 'campaigndrip'
});
// 4 is a sample ID representing an existing marketing campaign
campaign1.setCurrentSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'template',
    value: 4
}); 
campaign1.setCurrentSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'title',
    value: 'Sample Lead Nurturing Event'
}); 
// 1 is a sample ID representing an existing subscription 
campaign1.setCurrentSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'subscription',
    value: 1
}); 

// 2 is a sample ID representing an existing channel 
campaign1.setCurrentSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'channel',
    value: 2
}); 

// 1 is a sample ID representing an existing promocode 
campaign1.setCurrentSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'promocode',
    value: 1
}); 
campaign1.commitLine({
     sublistId: 'campaigndrip'
}); 

// Submit the record var 
campaign1Key = campaign1.save(); 

// Load the campaign record you created. Determine the internal ID of the campaign event to the variable campaign2_campaigndrip_internalid_1. 
var campaign2 = record.load({
    type: record.Type.CAMPAIGN,
    id : campaign1Key, 
    isDynamic: true
}); 
var campaign2_campaigndrip_internalid_1 = campaign2.getSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'internalid',
    line: 1
}); 
// 142 is a sample ID representing the ID of a recipient with a valid email address 
var campaignResponseId = email.sendCampaignEvent.promise({
    campaignEventId: campaign2_campaigndrip_internalid_1,
    recipientId: 142
}).then (function(result) {
    //Process the result
});
...
//Add additional code 

        

Related Topics

General Notices