onTabSave()
Registers and calls a callback method when a user clicks Save in a subtab’s Unsaved Changes dialog box. When using this method, call setTabUnsavedChanges() in the callback method. This notifies the console that the custom save operation completed. In the call to setTabUnsavedChanges(), pass the first parameter as false to indicate a successful save or true to indicate an unsuccessful save. This method is only available in API version 28.0 or later.
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.
When using onTabSave() with setTabUnsavedChanges():
- Calling
sforce.console.setTabUnsavedChanges(false,...)closes the specified subtab. We recommend placing the call tosforce.console.setTabUnsavedChanges()at the end of the callback method, as any subsequent save logic might not execute. onTabSave()works only on subtabs or their sidebar components. It doesn’t work on primary tabs.- Not calling
sforce.console.setTabUnsavedChanges()will have a severe effect on the user interface. For example, closing a primary tab with a subtab for whichsforce.console.setTabUnsavedChanges()has not been called prevents aSaving...modal dialog box from closing. - Any callback passed to
sforce.console.setTabUnsavedChanges()will not execute if the specified tab saves successfully and closes.
Calling onTabSave() from a custom console component prevents that component from refreshing when saving the subtab. ” in the Salesforce online help.
| Name | Type | Description |
|---|---|---|
callback | function | JavaScript method called to handle the save operation. |
| Name | Type | Description |
|---|---|---|
id | string | ID of the subtab being saved. |
objectId | string | Object ID of the subtab being saved, if applicable; null otherwise. |