0

Background: Attempting to create a send log for contacts who can make multiple enquiries on different services and models, but if they already have a record logged in this sendlog data extension with an existing email address, model and service match - to then have them pulled in an exclusion query for email sends they could also receive via another journey (as it exists in the sendlog).

Working with retention lists pulled in via data extension, and Email Send Log data extensions cannot be activated at this time.

Have tried the following but on test preview and send, neither seem to get the email sent out, let alone log this data.

UpsertDE:

    %%[
    VAR @EmailName, @EmailID, @model, @SubscriberKey, @Email

    SET @EmailName = '%%emailname_%%'
    SET @EmailID = '%%_emailid%%'
    SET @model = AttributeValue('model')
    SET @SubscriberKey = '%%_subscriberkey%%'
    SET @Email = '%%emailaddr%%'

    /* If no record exists with this Email Address, Email ID and Model combination, Insert Variables into the Data Extension */ 

    UpsertDE('ContactSendLog-UAT',3,'EmailAddress',@Email,'model',@model,'EmailID',@EmailID,'SubscriberKey',@SubscriberKey,'EmailName',@EmailName,'SendDate',NOW())

    ]%%

InsertDE:

    %%[
    VAR @EmailName, @EmailID, @model, @SubscriberKey, @Email

     SET @EmailName = '%%emailname_%%'
     SET @EmailID = '%%_emailid%%'
     SET @model = AttributeValue('model')
     SET @SubscriberKey = '%%_subscriberkey%%'
     SET @Email = '%%emailaddr%%'

     InsertDE('ContactSendLog-UAT','SubscriberKey',@SubscriberKey,'EmailAddress',@Email,'EmailName',@EmailName,'EmailID',@EmailID,'model',@model,'SendDate',NOW())

    ]%%

Any ideas on what could be going wrong here?

0

1 Answer 1

3

You can't mix inline (%%= =%%)and block-level (%%[ ]%%) AMPscript. Should be like this:

%%[
VAR @EmailName, @EmailID, @model, @SubscriberKey, @Email

SET @EmailName = emailname
SET @EmailID = _emailid
SET @model = AttributeValue('model')
SET @SubscriberKey = _subscriberkey
SET @Email = emailaddr

/* If no record exists with this Email Address, Email ID and Model combination, Insert Variables into the Data Extension */ 

UpsertDE('ContactSendLog-UAT',3,'EmailAddress',@Email,'model',@model,'EmailID',@EmailID,'SubscriberKey',@SubscriberKey,'EmailName',@EmailName,'SendDate',NOW())

]%%
3
  • Thanks Adam - guessing because it's being pulled by a %%=ContentBlockByID("x")=%%, this error message comes up: The SET variable value expression is invalid. See inner exception for detail. Script: SET @EmailName = emailname Variable Name: @EmailName ListID: 0 An error occurred when attempting to resolve a script expression. See inner exception for detail. Script Expression: emailname JobID: 0 An unrecognized expression appears in a script block. Script Expression: emailname JobID: 0
    – Salvara
    Commented Sep 24, 2018 at 17:25
  • Try wrapping each personalization string in an AttributeValue function like you did for model. Commented Sep 24, 2018 at 21:39
  • Thank you so much! That did the job :) Sat the content blocks above the template outside the script and it pulled in fine and registered even in preview test mode.
    – Salvara
    Commented Sep 25, 2018 at 9:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .