Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
%%[
VAR @subscriberkey, @email, @firstname, @lastname
SET @subscriberkey = _subscriberkey
IF NOT EMPTY(@subscriberkey) THEN
IF Substring(@subscriberkey, 1,3) == "00Q" THEN
/* Lead */
SET @rs= RetrieveSalesforceObjects("Lead", "Id, FirstName,LastName,Email", "Id", "=", @subscriberkey)
SET @rowCount = rowcount(@rs)
IF @rowCount > 0 THEN
SET @row = row(@rs,1)
SET @email = field(@row,"Email")
SET @firstname = field(@row,"FirstName")
SET @lastname = field(@row,"LastName")
ENDIF
ELSE
/* Contact */
SET @rs= RetrieveSalesforceObjects("Contact", "Id, FirstName,LastName,Email", "Id", "=", @subscriberkey)
SET @rowCount = rowcount(@rs)
IF @rowCount > 0 THEN
SET @row = row(@rs,1)
SET @email = field(@row,"Email")
SET @firstname = field(@row,"FirstName")
SET @lastname = field(@row,"LastName")
ENDIF
ENDIF
ELSE
SET @email = emailaddr
SET @firstname = ""
SET @lastname = ""
ENDIF
]%%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment