1

Is anybody able to confirm when you setup a Triggered Send Data Extension Template, it gives you the option to select a subscriber send relationship as your subscriber key, but in my case when I select another field other than SubscriberKey (Default Selected Field) it seems to just ignore my field and add a new record to All Subscribers with the SubscriberKey as EmailAddress. I also try to set the SubscriberKey in my Triggered Send payload to be SalesforceID and my Data Extension still populates the SubscriberKey field with EmailAddress, this seems like odd behaviour and not logical.

My SubscriberKey is set to be SalesforceID.

Current Setup:

Triggered Send Data Extension

SubscriberKey | EmailAddress | SalesforceID | FirstName | LastName

SalesforceID relates to Subscriber on SubscriberKey

Triggered Send Payload

{
    SubscriberKey: SalesforceID,
    EmailAddress: Email,
    SalesforceID: SalesforceID,
    FirstName: FirstName,
    LastName: LastName
}

After I perform a triggered send via SSJS along with the payload required, SubscriberKey is populated with EmailAddress and I look in All Subscribers and there is a new record created with EmailAddress as the SubscriberKey which should not happen in theory.

I have set the option to add my subscriber to All Subscribers under Subscriber Management but in theory it should marry it up with the Send Relationship I have selected like any other scenario I have previously setup in Marketing Cloud.

  • Do you think your triggered Send Payload hasn't defined optional attributes in nested objects? Also as per the documentation EmailAddress field is defined as Address developer.salesforce.com/docs/… – Brad Sapkota Jul 15 '18 at 11:28
  • So I am using the TriggeredSend Function in SSJS, which gives you the option to pass the email recipient along with a send attribute payload. That link you have suggested is referencing the REST API documentation. – thechrishaddad Jul 15 '18 at 23:28
2

You shouldn't tamper with the Subscriber Key relationship when creating a DE from a Triggered Send DE template. The generated relationship of SubscriberKey field should equal the Subscriber Key value in your Triggered Send DE; don't override this relationship.

As per the documentation, the Triggered Send core SSJS function that is used to send a Triggered Send email does not support the use of subscriber key as a valid parameter.

You have a couple of options here.

Option 1: Use the platform API function

<script runat="server">
Platform.Load("Core","1");

var ts = Platform.Function.CreateObject('TriggeredSend');
var tsDefinition = Platform.Function.CreateObject('TriggeredSendDefinition');
var customerKey = 'insertYourCustomerKeyHere';
var emailaddr = 'someone@company.com';
var salesforceId = '003G000002haA2A';
var firstName = 'Eliot'
var lastName = 'Harper'

Platform.Function.SetObjectProperty(tsDefinition, 'CustomerKey', customerKey);
Platform.Function.SetObjectProperty(ts, 'TriggeredSendDefinition', tsDefinition);

var subscriber = Platform.Function.CreateObject('Subscriber');
Platform.Function.SetObjectProperty(subscriber, 'EmailAddress', emailaddr);
Platform.Function.SetObjectProperty(subscriber, 'SubscriberKey', salesforceId);

var attributes = Platform.Function.CreateObject('Attribute');
Platform.Function.SetObjectProperty(attributes, 'Name', 'FirstName');
Platform.Function.SetObjectProperty(attributes, 'Value', firstName);
Platform.Function.AddObjectArrayItem(subscriber,'Attributes', attributes);

var attributes = Platform.Function.CreateObject('Attribute');
Platform.Function.SetObjectProperty(attributes, 'Name', 'LastName');
Platform.Function.SetObjectProperty(attributes, 'Value', lastName);
Platform.Function.AddObjectArrayItem(subscriber,'Attributes', attributes);

Platform.Function.AddObjectArrayItem(ts, 'Subscribers', subscriber);

var statusAndRequestID = [0,0];

var statMsg = Platform.Function.InvokeCreate(ts, StatusAndRequestID, null);
Platform.Response.Write('status message: ' + statMsg);

</script>

Option 2: Use the platform API function with WSProxy

You can achieve the same platform API function using the new WSProxy for SSJS. This achieves the same result as the platform API function, but replaces the highly verbose, procedural programming approach to interacting with SOAP API objects with a simpler, declarative approach:

<script runat="server">
var prox = new Script.Util.WSProxy();
var customerKey = "insertYourCustomerKeyHere"
var emailaddr = "someone@company.com";
var salesforceId = "003G000002haA2A"; 
var firstName = "Eliot";
var lastName = "Harper";

var ts = {
    TriggeredSendDefinition: {
      CustomerKey: customerKey
      },
    Subscribers: [{
      EmailAddress: emailaddr,
      SubscriberKey: salesforceId,
      Attributes: [{
        Name: "FirstName",
        Value: firstName
      },
      {
        Name: "LastName",
        Value: lastName
      }]
    }]
}

var res = prox.createItem("TriggeredSend", ts);
</script>
  • 1
    I did not test Option 1 but Option 2 works a charm, The subscriber key attribute gets mapped correctly using the WSProxy functionality, although I constructed my attribute array of objects dynamically to eliminate future amends when new data is required. Thank you – thechrishaddad Jul 17 '18 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.