Create a Personalized Email with Custom Object Data

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.

  1. In Engagement, go to Email Studio.
  2. Click Content.
  3. Click Create.
  4. Select HTML Paste.
  5. Enter an email name and subject line.
  6. 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.

  7. Save the email.