saveLog() for Lightning Experience for Lightning Experience
Usage
Saves or updates an object in Salesforce. This method is available in API version 38.0 or later.
Syntax
1sforce.opencti.saveLog({
2 value:{
3 entityApiName:string, //Optional
4 Id:string, //Optional
5 param:value //Optional
6 },
7 callback:function //Optional
8})Arguments
| Name | Type | Description |
|---|---|---|
| value | object | Specifies the fields to save or update on the object. If the
object’s ID is specified, a record is updated. For
example:
If
the object’s ID isn’t specified, a new record is created. For
example:
|
| callback | function | JavaScript method executed when the API method call is completed. |
Sample Code–HTML and JavaScript
1<html>
2<head>
3 <script type="text/javascript" src="http://domain:port/support/api/66.0/lightning/opencti_min.js"></script>
4 <script type="text/javascript">
5 var callback = function (response) {
6 if (response.result) {
7 console.log('API method call executed successfully! returnValue:', response.returnValue);
8 } else {
9 console.error('Something went wrong! Errors:', response.errors);
10 }
11 }
12 function saveLog() {
13 //Update an existing object with the ID specified
14 sforce.opencti.saveLog({value:{Id:"00QR0000000yN5iMAE", LastName:"New lastname" }, callback:callback});
15 //Create a contact
16 sforce.opencti.saveLog({value:{entityApiName:"Contact", LastName:"LastName" },callback:callback});
17 //Update a lead
18 sforce.opencti.saveLog({value:{Id:"00QR0000000yN5iMAE", LastName:"New lastname" },callback:callback});
19 }
20 </script>
21</head>
22<body>
23 <button onclick="saveLog();">saveLog</button>
24</body>
25</html>Response
This method is asynchronous. The response is returned in an
object passed to a callback method. The response object contains the following
fields.
| Name | Type | Description |
|---|---|---|
| success | boolean | Returns true if the API method call was invoked successfully, false otherwise. |
| returnValue | object | ID of object if creating or updating the object was successful; null if creating or updating the object wasn’t successful. |
| errors | array | If the API call was successful, this variable is null. If the API call failed, this variable returns an array of error messages. |