# saveLog() for Salesforce Classic

## Usage

Saves or updates an object in Salesforce.

:::note
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.
:::

## Syntax

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

## Arguments

| Name         | Type     | Description                                                                                                                                                                                                                                                                      |
| ------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `object`     | string   | The name of the object to save or update.                                                                                                                                                                                                                                        |
| `saveParams` | string   | Specifies 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`. |
| `callback`   | function | JavaScript method executed when the API method call is completed.                                                                                                                                                                                                                |

## Sample Code–JavaScript

```javascript
<html>
<head>
   <script type="text/javascript" src="http://domain:port/support/api/25.0/interaction.js"></script>
   <script type="text/javascript">
       var callback = function (response) {
           if (response.result) {
                  alert(response.result);
           } else { 
                  alert(response.error);
           }
       } 
       function saveLog() {
           //Invokes API method
                sforce.interaction.saveLog('Account','Name=NewAccountName&Phone=4155551212', callback);
       } 
</script>
</head>
   <button onclick="saveLog();">saveLog</button>
</html>
```

## Response

| Name     | Type    | Description                                                                                                                 |
| -------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
| `result` | boolean | `true` if saving or updating the object was successful, `false` if saving or updating the object wasn’t successful.         |
| `id`     | string  | The Id of the newly created object.                                                                                         |
| `error`  | string  | If the API call was successful, this variable is undefined. If the API call failed, this variable returns an error message. |
