You are here:
Create a Personalized Email with Standard Object Data
For this Marketing Cloud Connect for Marketing Cloud Engagement tutorial example, create a personalized email from a case with standard object data using AMPscript.
- In Engagement, go to Email Studio.
- Click Content.
- Click Create.
- Click HTML Paste.
- Enter a name and a subject.
-
In the email content area, insert this AMPscript.
%%[ Set @mySObject = SObject Set @myRecordId = RecordId set @Case = RetrieveSalesforceObjects(SObject,"Subject,Status","Id", "=", RecordId) Set @CaseRow = Row(@Case, 1) Set @Subject = FIELD(@CaseRow, "Subject") Set @Status = FIELD(@CaseRow, "Status") ]%% <br> <br> SObject From API Call: %%=v(@mySObject)=%% <br> RecordId From API Call: %%=v(@myRecordId)=%% <br> Subject From RetrieveSalesforceObjects: %%=v(@Subject)=%% <br> Status From RetrieveSalesforceObjects: %%=v(@Status)=%% <br> - Save the email.
-
Modify the AMPscript example to include extra customizations.
To add more fields from the case, follow this format. For
example, include the Description field.
set @Case = RetrieveSalesforceObjects(SObject,"Subject,Status,Description","Id", "=", RecordId) -
To set the Description variable, add another line of code. For
example, under line 6 add this code.
Set @Description = FIELD(@CaseRow, "Description").Add this code within the closing tag ]%%.
-
To print the Description field in an email, add another line of
code under the last line.
Status From RetrieveSalesforceObjects: %%=v(@Description)=%% <br>
New AMPscript looks like this example.
%%[
Set @mySObject = SObject
Set @myRecordId = RecordId
set @Case = RetrieveSalesforceObjects(SObject,"Subject,Status","Id", "=", RecordId)
Set @CaseRow = Row(@Case, 1)
Set @Subject = FIELD(@CaseRow, "Subject")
Set @Status = FIELD(@CaseRow, "Status")
Set @Description = FIELD(@CaseRow, "Description")
]%%
<br>
<br>
SObject From API Call: %%=v(@mySObject)=%%
<br>
RecordId From API Call: %%=v(@myRecordId)=%%
<br>
Subject From RetrieveSalesforceObjects: %%=v(@Subject)=%%
<br>
Status From RetrieveSalesforceObjects: %%=v(@Status)=%%
<br>
Description From RetrieveSalesforceObjects: %%=v(@Description)=%%
<br>
