0
%%[
Var @EventName, @EventStartDate, @EventID, @FirstName, @SubscriberKey, @EventEndDate 
SET @SubscriberKey = AttributeValue("_subscriberkey") 
SET @EventID = Lookup("ContactToOnlineEvent","Event ID","uuid",@SubscriberKey) 
SET @EventName = Lookup("OnlineEvent","Event Name","Event ID",@EventID) 
SET @EventStartDate = Lookup("OnlineEvent","Event start date","Event ID",@EventID)
SET @EventEndDate = Lookup("OnlineEvent","Event end date","Event ID",@EventID)
SET @FirstName = Lookup("ContactToOnlineEvent","First Name","uuid",@SubscriberKey)
SET @EventStartDate = FormatDate(@EventStartDate,"dd/MM/YYYY","HH:mm tt","pt-BR")
SET @EventEndDate = FormatDate(@EventEndDate,'','HH:mm')

]%%

Above is the AMPscript I have in my email. The issue I am facing right now is the wrong EventName is being pulled into the email if a record has registered for multiple events. It seems to be pulling the EventName from the first records listed in the data extension, and not the one that matches the Event ID in the data extension it is sending to.

The sending data extension is called STG_Registered_Customers, which contains 3 fields. Event ID, uuid (subscriber key), and Email Address

The ContactToOnlineEvent data extension has the following fields, Event ID, uuid (subscriber key), Email Address, and other fields like first, last name, attended status and such.

The OnlineEvent data extension contains the following fields, Event ID, Event Name, EventStartDate, EventEndDate.

Is there a way for me to get the correct event name that matches with the Event ID in the STG_Registered_Customers data extension I am sending to?

2

This is the case because you did only specify the subscriberkey as a column identifying your desired value/row. The lookup-function provides the possibility to add further key-value pairs as a selector to narrow down the results.

Furthermore you are pulling the EventID via Lookup rather than the sending data extension. You can use the AttributeValue funtion to retrieve this data from your sending data extension just like you did with "_subscriberkey", but with using the column name of the eventid instead.

So you code could look like this:

%%[
    Var @EventName, @EventStartDate, @EventID, @FirstName, @SubscriberKey, @EventEndDate 
    SET @SubscriberKey = AttributeValue("_subscriberkey")

    /* I changed the retrieval to the sending data extension rather than the ContatToOnlineEvent data extension, as the information is already present there  */
    SET @EventID = AttributeValue("Event ID")

    SET @EventName = Lookup("OnlineEvent","Event Name","Event ID",@EventID) 
    SET @EventStartDate = Lookup("OnlineEvent","Event start date","Event ID",@EventID)
    SET @EventEndDate = Lookup("OnlineEvent","Event end date","Event ID",@EventID)

    /* I added the event id as further field for the lookup */
    SET @FirstName = Lookup("ContactToOnlineEvent","First Name","uuid",@SubscriberKey, "Event ID", @EventID)
    SET @EventStartDate = FormatDate(@EventStartDate,"dd/MM/YYYY","HH:mm tt","pt-BR")
    SET @EventEndDate = FormatDate(@EventEndDate,'','HH:mm')
]%%

Related documentation:

| improve this answer | |
  • I made the recommended changes and it is now pulling the correct event name. Thank you so much for your help and the quick response! – RunRabbit Jun 10 at 14:18

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.