Skip to content

Instantly share code, notes, and snippets.

@MamaiRachid
Created October 20, 2020 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MamaiRachid/95574a7cb6060993fcf2610e541b236f to your computer and use it in GitHub Desktop.
Save MamaiRachid/95574a7cb6060993fcf2610e541b236f to your computer and use it in GitHub Desktop.
Unsubscribe contact from newsletterEmailConsent on Sales Cloud by creating a Task
%%[
/* Check if the contact is subscribed to the newsletterEmail_Consent */
IF (@newsletterEmail_Consent != 'False') THEN
SET @timeNow = FormatDate(Now(),"iso")
SET @created_taskId= CreateSalesforceObject('Task',4,'WhoId', @subKey, 'Subject', 'Datapm:Unsubscribe', 'Description', '{"crCode":"100001"}', 'ActivityDate', @timeNow)
/* Update Consents Data Extension */
UpsertData("Consents", 1, "SubscriberKey", @subKey, "NewsletterEmail_Consent", "False")
ENDIF
]%%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment