Skip to content

Instantly share code, notes, and snippets.

@MamaiRachid
Last active November 6, 2020 13:00
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/88f6ab73be9131008f594c1d95c2d68f to your computer and use it in GitHub Desktop.
Save MamaiRachid/88f6ab73be9131008f594c1d95c2d68f to your computer and use it in GitHub Desktop.
Code Snippet AMPScript code to unsubscribe a contact from Sales Cloud through a creation of a Task (Data Privacy app)
%%[ var @rows, @row, @rowCount, @subKey, @counter
set @rows = LookupRows("BRANDA_COMPLAINTS","OYBAccountID","50000XXXX","Secret", 1)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
for @counter = 1 to @rowCount do
set @row = row(@rows, @counter)
set @subKey = field(@row,"SubscriberKey")
set @created_taskId= CreateSalesforceObject('Task',3,'WhoId', @subKey, 'Subject', 'Datapm:Unsubscribe', 'Description', '{"channel":"email"}')
next
endif
InsertDE("COMPLAINTS_LOG","SubscriberKey", @subKey,"Event_Date", FormatDate(Now(),"iso"))
]%%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment