saveLog() for Salesforce Classic

Usage 

Saves or updates an object in Salesforce.

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. For person accounts, you can’t pass the person account recordType if the profile’s default is to a business account.

Note

Syntax 

1sforce.interaction.saveLog(object:string, saveParams:string, (optional)callback:function)

Arguments 

NameTypeDescription
objectstringThe name of the object to save or update.
saveParamsstringSpecifies the fields to save or update on the object.If the object’s ID is specified, a record is updated. For example: Id=001D000000J6qIX&Name=Acme&Phone=4154561515. If the object’s ID isn’t specified, a new record is created. For example: Name=Acme&Phone=4154561515.
callbackfunctionJavaScript method executed when the API method call is completed.

Sample Code–JavaScript 

1<html>
2<head>
3   <script type="text/javascript" src="http://domain:port/support/api/25.0/interaction.js"></script>
4   <script type="text/javascript">
5       var callback = function (response) {
6           if (response.result) {
7                  alert(response.result);
8           } else { 
9                  alert(response.error);
10           }
11       } 
12       function saveLog() {
13           //Invokes API method
14                sforce.interaction.saveLog('Account','Name=NewAccountName&Phone=4155551212', callback);
15       } 
16</script>
17</head>
18   <button onclick="saveLog();">saveLog</button>
19</html>

Response 

NameTypeDescription
resultbooleantrue if saving or updating the object was successful, false if saving or updating the object wasn’t successful.
idstringThe Id of the newly created object.
errorstringIf the API call was successful, this variable is undefined. If the API call failed, this variable returns an error message.