CreateSalesforceObject Function

The CreateSalesforceObject function creates a record in an object in Salesforce (both standard and custom objects). The ID of the record is returned. You need to have the connector enabled and configured correctly in order for this AMPscript function to work. You do not need to have the object synced via Synchronized Data Extensions.

A simple use case is using the CreateSalesforceObject function in a CloudPage where you may want a record created after a form submit on the CloudPage.

Syntax:

                    

CreateSalesforceObject(1,2,3,4)
1 = Salesforce Object: Account, Contact, Lead, Opportunity (or custom object)
2 = Number of fields to add to record (Include required fields)
3 = Field name to use 
4 = Value of field (Can be variables)

                

Example:

                    

%%[
var @createContact, @firstName, @lastName, @emailAddress
set @createContact = CreateSalesforceObject(‘Contact’, 3, ‘FirstName’, @firstName, ‘LastName’, @lastName, ‘Email’, @emailAddress)

]%%


                

Output:

0033000000GvHmL

Explanation:

The CreateSalesforceObject function is used to create a record in Sales or Service Cloud that is integrated with Marketing Cloud. The @createContact variable is used in the create function to create a record on the Contact object. The fields we want to create in Contact are the FirstName, LastName, and Email fields. Since there are three fields to be specified in this new record, we use the number 3 in the second parameter.

Related functions are the RetrieveSalesforceObjects function and the UpdateSingleSalesforceObjects function

Leave a Reply

Your email address will not be published. Required fields are marked *