For this Marketing Cloud Connect for Marketing Cloud Engagement tutorial example, create a personalized email from a case with custom object data using AMPscript.
Assume that you have a custom object called Application with a lookup to the Contact object. The Application custom object has two fields: University_Name__c and Course_Name__c.
- In Engagement, go to Email Studio.
- Click Content.
- Click Create.
- Select HTML Paste.
- Enter an email name and subject line.
-
In the email content area, insert this AMPscript.
%%[ Set @mySObject = SObjectSet @myRecordId = RecordIdset @Application = RetrieveSalesforceObjects(@mySObject,"University_Name__c,Course_Name__c","Id", "=", @myRecordId) Set @ApplicationRow = Row(@Application, 1) Set @University_Name = FIELD(@ApplicationRow, "University_Name__c") Set @Course_Name = FIELD(@ApplicationRow, "Course_Name__c") ]%%<br> <br>SObject From API Call: %%=v(@mySObject)=%% <br>RecordId From API Call: %%=v(@myRecordId)=%% <br>University Name From RetrieveSalesforceObjects: %%=v(@University_Name)=%% <br>Course Name From RetrieveSalesforceObjects: %%=v(@Course_Name)=%% <br>When referencing custom object fields, include the Sales Cloud field name and the underscore _. For example, University_Name__c.
- Save the email.