2
%%[ VAR @EventType, @DateTime, @Address
SET @EventType = Lookup("CampaignMember_Contact_Builder", "Event_Type__c", "ContactId", _subscriberkey)
SET @DateTime = Lookup("CampaignMember_Contact_Builder", "Event_Date__c", "ContactId", _subscriberkey)
SET @Address = Lookup("CampaignMember_Contact_Builder", "Address__c", "ContactId", _subscriberkey)]%%

Having trouble with my lookup function. When called, these vars are not returning anything in preview. All data comes from Salesforce using the connector.

  • How are you calling the values? – Samuel Dare Sep 11 '17 at 20:31
  • Is this an email or a landing page? – Samuel Dare Sep 11 '17 at 20:42
  • @Data_Kid WHO: %%=v(@who)=%% WHAT: %%=v(@EventType)=%% WHEN: %%=v(@DateTime)=%% WHERE: %%=v(@Address)=%% – Stephanie Wood Sep 11 '17 at 20:52
  • @Data_Kid This is an email. – Stephanie Wood Sep 11 '17 at 20:53
  • @Data_Kid It works with one subscriber in preview but none of the others. Have a feeling something is wonky with the Id's but can't figure out what's not registering with the system – Stephanie Wood Sep 11 '17 at 20:54
0

Try using the attribute value ampscript function to capture the subscriberkey.

eg

%%[ VAR @EventType, @DateTime, @Address , @SubscriberKey

SET @SubscriberKey = AttributeValue("_subscriberkey")
SET @EventType = Lookup("CampaignMember_Contact_Builder", "Event_Type__c", "ContactId", @SubscriberKey)
SET @DateTime = Lookup("CampaignMember_Contact_Builder", "Event_Date__c", "ContactId", @SubscriberKey)
SET @Address = Lookup("CampaignMember_Contact_Builder", "Address__c", "ContactId", @SubscriberKey)]%%
  • I tried this and got the same results. – Stephanie Wood Sep 11 '17 at 21:08
  • Try doing just %%=v(@SusbcriberKey)=%% in your preview to see if the ones that fail have null/ malformed value/ emailaddress. Are all your subscribers coming from salescloud? you might find that in some instances the subscriberkey is an emailaddress , therefore it wont map onto ContactId in CampaignMember_Contact_Builder – Samuel Dare Sep 11 '17 at 21:18
  • @StephanieWood the suggestion above – Samuel Dare Sep 11 '17 at 21:27
  • The subscriber key is showing up fine when I preview in the email showing as an 18 digit SF record id like it's supposed to. Yes all our subscribers come from salesforce. Any other ideas? I might have to take this to support. @Data_Kid – Stephanie Wood Sep 12 '17 at 12:32
  • @StephanieWood Im all out of ideas sorry x – Samuel Dare Sep 12 '17 at 13:09
0

I think the answer to your question depends on how your Data Extension is populated.

If it's a Synchronized Data Extension, then you can retrieve it like this:

%%[

var @rows, @row, @rowCount, @sk

set @sk = AttributeValue("_subscriberkey")

output(concat("<br>sk: ",@sk))

set @rows = LookupRows("CampaignMember_Salesforce","ContactId", @sk)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

    var @EventType, @DateTime, @Address
    set @row = row(@rows,1) 
    set @EventType = field(@row,"EventType")
    set @DateTime = field(@row,"DateTime")
    set @Address = field(@row,"Address")

    output(concat("<br>EventType: ",@eventType))
    output(concat("<br>DateTime: ",@DateTime))
    output(concat("<br>Address: ",@Address))

else

    output(concat("<br>no rows found"))

endif

]%%

Or you can retrieve it directly from Sales Cloud like this:

%%[

var @rows, @row, @rowCount, @sk

set @sk = AttributeValue("_subscriberkey")

output(concat("<br>sk: ",@sk))

set @rows = RetrieveSalesforceObjects("CampaignMember","EventType,DateTime,Address","ContactId", "=", @sk)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

    var @EventType, @DateTime, @Address
    set @row = row(@rows,1) 
    set @EventType = field(@row,"EventType")
    set @DateTime = field(@row,"DateTime")
    set @Address = field(@row,"Address")

    output(concat("<br>EventType: ",@eventType))
    output(concat("<br>DateTime: ",@DateTime))
    output(concat("<br>Address: ",@Address))

else

    output(concat("<br>no rows found"))

endif

]%%

Reference

  • The issue was because there was a one to many relationship to the Lookup DE and therefore it wasn't pulling the right row of data. I'm now looking at ways I can identify the row that will be needed for that point in time. – Stephanie Wood Sep 15 '17 at 18:54

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.