3

We have built a email for distributed marketing. The email will preform a lookup on a Stored DE to dynamically display the store address associated with the send. This is accomplished by taking the campaignID, which is stored in the "sfcampaignId" field and then retrieve the store id from the campaign details on the campaign object in Service Cloud.

The preview/test send is working fine within Marketing Cloud when using data pushed via Distributed Marketing. But when we are trying to send a Email from Experience Cloud the Email preview do not work. The error in Experience Cloud just state, "Please contact Marketing cloud Admin".

Below is the ampscript used in the email. We've narrowed down the error is being caused by one line of code. SET @sfCampaignId = AttributeValue("sfCampaignId")

We are stumped, because I would expect the @sfCampaignId variable to at least be set to an empty string if the attribute could not be found.

%%[
VAR @sfCampaignId, @StoreNumber, @City, @Address1, @Address2 
SET @sfCampaignId = AttributeValue("sfCampaignId")
VAR @Rows
SET @Rows = RetrieveSalesforceObjects(
   "Campaign",
   "Store__C,Name,Id",
   "Id", "=", @sfCampaignId )
   
   Output(Concat(Rowcount(Rows)))
IF RowCount(@Rows) == 1 then
  VAR @row, @StoreNumber, @City, @Address1, @Address2, @State
  SET @row = Row(@Rows, 1)
  SET @stores = Field(@row, "Store__C")
  SET @campaignName = Field(@row, "Name")
  
ENDIF
  SET @StoreNumber = Lookup("ent.Store__c_Salesforce","External_Store_ID__c","id", @stores)
  SET @Address1 = Lookup("ent.Store__c_Salesforce","Address1__c","id", @stores)
  SET @Address2 = Lookup("ent.Store__c_Salesforce","Address2__c","id", @stores)
  SET @City = Lookup("ent.Store__c_Salesforce","City__c","id", @stores)
  SET @State = Lookup("ent.Store__c_Salesforce","State__c","id", @stores)
]%% 
4
  • What happens if you do AttributeValue("cid") instead? May 5, 2022 at 17:42
  • Thanks @AdamSpriggs, we will try that and report back. Based off online documentation, we were instructed to setup the DE with a field named sfCampaignId. reference: help.salesforce.com/s/… May 5, 2022 at 17:46
  • I'm wondering if there's an alternate context for these sends -- perhaps referencing encrypted qs for the context instead of an actual DE row. Like a TSD without an associated DE. May 5, 2022 at 17:53
  • If you comment out everything but your retrieve and rowcount output, what do you get? Also, shouldn't your ENDIF be after the SET @State? May 6, 2022 at 14:17

1 Answer 1

0

When previewing the Distributed Marketing email from Experience Cloud, the _MessageContext AMPscript personalization contains a value of 'PREVIEW'. Since the Destributed Marketing email preview does not like the SET @sfCampaignId = AttributeValue("sfCampaignId") line of code, I've added some conditional logic to not run this code while in PREVIEW mode.

There are multiple StackExchange questions around the technique of conditionally running AMPscript based on _MessageContect. I've referenced one here.

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.