Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
onTabSave()
Registering a callback method affects the user interface. When no save handler is registered, the user is presented with two options when closing a subtab with unsaved changes: Continue or Cancel. When a save handler is registered, the user is presented with three options when closing the subtab: Save, Don’t Save, or Cancel. In this scenario, the callback method registered is called when the user chooses Save.
Syntax
1sforce.console.onTabSave(callback:Function)Arguments
| Name | Type | Description |
|---|---|---|
| callback | function | JavaScript method called to handle the save operation. |
Sample Code–Visualforce
1<apex:page>
2 <a href="#" onClick="testOnTabSave();return false">
3 Click here to register save handler</a>
4
5 <apex:includeScript value="/support/console/68.0/integration.js"/>
6 <script type="text/javascript">
7 function testOnTabSave() {
8 sforce.console.onTabSave(handleSave);
9 }
10 var handleSave = function handleSave(result) {
11 alert('save handler called from tab with id ' + result.id +
12 ' and objectId ' + result.objectId);
13 //Perform save logic here
14
15 //Mark tab as 'clean'
16 sforce.console.setTabUnsavedChanges(false, undefined, result.id);
17 };
18 </script>
19</apex:page>Response
| Name | Type | Description |
|---|---|---|
| id | string | ID of the subtab being saved. |
| objectId | string | Object ID of the subtab being saved, if applicable; null otherwise. |