The Salesforce Developers website will undergo maintenance on May 29, 2024 from 3:00 a.m. UTC to 10:00 a.m. UTC. The maintenance process may affect the availability of our documentation. Please plan accordingly.


Creates a record in a Sales Cloud or Service Cloud object and returns the ID of the record created.

When you call this function, it issues a SOAP request to your Salesforce org. As a result, the function is subject to the API limits that apply to your Salesforce org. We recommend that you minimize your use of this function in sends. Using this function in large sends can result in the sends failing to complete.

To use this function, you must use Marketing Cloud Connect to integrate with Sales Cloud or Service Cloud.

The CreateSalesforceObject() function has four parameters.

  • objectName (string): Required. The API name of the Salesforce object to insert the record into.
  • numFields (string): Required. The number of fields to insert. This number must match the number of name-value pairs that you specify in the function.
  • fieldName1 (string): Required. The name of the field to insert in the object.
  • fieldValue1 (string): Required. The value to insert for the field.

You can optionally upsert additional keys and values ([fieldName2, fieldValue2 ...]) by appending each key-value pair to the list of parameters. You can upsert as many keys and values as necessary in this way.

To use the function, pass it the name of the object that you want to insert fields into. Next, specify the number of fields to insert. Finally, add the names and values of the records that you want to insert.

This example creates a lead in the integrated Salesforce account with a single field, EmailAddress.

The function returns the ID of the newly created record.

This example creates a lead with FirstName, LastName, and EmailAddress fields.

The function returns the ID of the newly created record.