Last active
January 14, 2020 13:22
-
-
Save zuzannamj/ecf38a80640ed12b60c3a9b88e91029c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF RequestParameter("submitted") == true AND RequestParameter("unsub") == true THEN | |
/* update contact in Sales Cloud */ | |
SET @updateRecord = UpdateSingleSalesforceObject( | |
"Contact", @contactId, | |
"Newsletter__c", "false", | |
"Events__c", "false", | |
"Offers__c", "false", | |
"HasOptedOutOfEmail", "true" | |
) | |
/* log unsubscribe event to mark as unsubscribed in All Subscribers */ | |
SET @reason = "Unsubscribed through custom subscription center" | |
SET @lue = CreateObject("ExecuteRequest") | |
SETObjectProperty(@lue,"Name","LogUnsubEvent") | |
SET @lue_prop = CreateObject("APIProperty") | |
SETObjectProperty(@lue_prop, "Name", "SubscriberKey") | |
SETObjectProperty(@lue_prop, "Value", @contactId) | |
AddObjectArrayItem(@lue, "Parameters", @lue_prop) | |
SET @lue_prop = CreateObject("APIProperty") | |
SETObjectProperty(@lue_prop, "Name", "Reason") | |
SETObjectProperty(@lue_prop, "Value", @reason) | |
AddObjectArrayItem(@lue, "Parameters", @lue_prop) | |
SET @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment