0

I'm trying to use the CampaignMember:Id as a variable to update the Campaign Member Status when an email is sent.

I've tried this AMPscript but receive the following error: "Script SET Statement Invalid
An error occurred when attempting to resolve a script expression. See inner exception for detail. Script Expression: CampaignMember:Id"

 %%[
 var @CampaignMemberId, @result

 set @CampaignMemberId = CampaignMember:Id
 set @result = UpdateSingleSalesforceObject("CampaignMember", 
 @CampaignMemberId, "Status", "Sent")
 ]%%

This AMPscript works but doesn't do me any good.

 %%[
 var @result

 set @result = UpdateSingleSalesforceObject("CampaignMember", "00v1R00001dk2lJQAQ", "Status", "Sent")
 ]%%

This is possible, right? Am I missing something?

Update: I was able to get the Campaign Member activity to update the Status in Journey Builder using the Find and Update setting. I would still like to know why I can't use the CampaignMember:Id attribute as a variable in AMPscript. Ideally, a new Campaign Member is created for every Status change so we can track every touch point in the reports.

6
  • Why don't you do this in a journey and use the drag and drop functionality to update salesforce campaign member status? Mar 12, 2019 at 6:26
  • The CampaignMember activity was my first idea but was not able to get it working. I wasn’t able to get the status to update in SF.
    – Kyle Szabo
    Mar 12, 2019 at 6:30
  • Sounds like an issue with your connector to salesforce... Have you checked it? Mar 12, 2019 at 6:32
  • Connecter seems to be working, Salesforce campaigns is the entry event to the journey and leads/contacts are entered and sent an email when added to the campaign.
    – Kyle Szabo
    Mar 12, 2019 at 6:37
  • Using the same Campaign Member activity for Leads and Contacts could probably be the problem. Try using two paths. One campaign member activity per path. First path for Contacts, and the second one for Leads. That's because you need to choose between Contact ID or Lead ID when creating the Campaign member in the first place. Mar 12, 2019 at 11:20

1 Answer 1

4

There are two things here.

1) The MC Connector is able to automatically update the Campaign Member Status after an Email has been sent.

This is part of the package and very quick to implement. Granted, it doesn't do the update instantly, but it's still a very solid configuration to have it place when sending to Campaign Members.

Log in to Sales Cloud and go to Marketing Cloud tab > Configure Marketing Cloud:

MC connector

MC connector2

2) There is a small issue with your script, here is the correct way of setting it.

set @CampaignMemberId = AttributeValue("CampaignMember:Id")

4
  • Thank you for your reply. I tried the script with AttributeValue and receive the following error: "Call to update the salesforceobject CampaignMember ID = 00v1R00001dk2MqQAI failed! Error status code: INVALID_CROSS_REFERENCE_KEY Error message: invalid cross reference id" Ideally, I would like to update or create a new Campaign Member with a Salesforce activity in Journey Builder, but it's not working. I would like to track the status from added, sent, opened, clicked, and responded. When I add the Campaign Member activity to the canvas, no errors are shown but the status never gets updated
    – Kyle Szabo
    Mar 12, 2019 at 15:04
  • Super strange, you should be able to reference that attribute. Can you double check that this attribute exists in your Data Extension with this column name?
    – Rain
    Mar 12, 2019 at 20:15
  • Hi Rain, I have confirmed this attribute exists in the Data Extension with this column name. I am using it on a CloudPage to populate hidden form fields, it just won’t work in the email. The Campaign Member activity is working in the Journey, my original idea to create a new campaign member for each status change won’t work because SF doesn’t allow adding duplicate records to the campaign.
    – Kyle Szabo
    Mar 13, 2019 at 15:32
  • @Rain Will campaign member tracking events (as you've shown in 1) be sent back to SFDC via MC Connector when emails are sent to Campaign Members in a Journey configured with SF Data entry? Jul 31, 2019 at 6:59

You must log in to answer this question.

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