saveLog() for Lightning Experience

Saves or updates an object in Salesforce. This method is available in API version 38.0 or later.

  • To update using this method, include Id.
  • To create using this method, include entityApiName.
  • If an object uses recordType, pass the recordTypeId in the saveLog call. If you don’t pass the recordType, the record is created using the default recordType for the profile. To create a person account, you can pass the person account recordType if the profile’s default is to a business account.
  • To refresh after you update or create using this method, call the refreshView method in the callback method.
NameTypeDescription
valueobjectSpecifies the fields to save or update on the object. If the object’s ID is specified, a record is updated. If the object’s ID isn’t specified, a new record is created. Ensure all required fields are specified when creating a record.
callbackfunctionJavaScript method executed when the API method call is completed.

To update a record, include the object’s ID in value:

To create a record, include entityApiName instead:

This method is asynchronous. The response is returned in an object passed to a callback method. The response object contains the following fields.

NameTypeDescription
successbooleanReturns true if the API method call was invoked successfully, false otherwise.
returnValueobjectID of object if creating or updating the object was successful; null if creating or updating the object wasn’t successful.
errorsarrayIf the API call was successful, this variable is null. If the API call failed, this variable returns an array of error messages.