setTabUnsavedChanges()

Sets the unsaved changes icon (Unsaved changes on tab icon ) on subtabs to indicate unsaved data. This method is only available in API version 23.0 or later.

Syntax 

1sforce.console.setTabUnsavedChanges(unsaved:Boolean, callback:Function, (optional)subtabId:String)

Arguments 

NameTypeDescription
unsavedbooleanIf true, the tab is marked as having unsaved changes.
callbackfunctionJavaScript method that’s called upon completion of the method.
subtabIdstringThe ID of the subtab that is marked as having unsaved changes. This argument is only available in API version 25.0 or later.

Sample Code API Version 23.0 or Later–Visualforce 

1<apex:page standardController="Case">
2    <A HREF="#" onClick="testSetTabUnsavedChanges();return false">
3           Click here to indicate this tab has unsaved changes</A> 
4
5<apex:includeScript value="/support/console/68.0/integration.js"/>
6    <script type="text/javascript">
7        function testSetTabUnsavedChanges() { 
8            sforce.console.setTabUnsavedChanges(true, displayResult);
9        };
10        function displayResult(result) {
11             if (result.success) {
12                 alert('Tab status has been successfully updated');
13             } else {
14                 alert('Tab status couldn’t be updated');
15             }
16        }
17
18    </script>
19</apex:page>

To see this example in action, click the custom link on a case. For more information, see Define Custom Buttons and Links in the Salesforce help.

Note

Response 

This method returns its response in an object in a callback method. The response object contains the following field:

NameTypeDescription
successbooleantrue if update was successful; false if update wasn’t successful.

Sample Code API Version 25.0 or Later–Visualforce 

1<apex:page standardController="Case">
2    <A HREF="#" onClick="testSetTabUnsavedChanges();return false">
3           Click here to indicate this tab has unsaved changes</A> 
4
5    <apex:includeScript value="/support/console/25.0/integration.js"/>
6    <script type="text/javascript">
7         function testSetTabUnsavedChanges() {
8            sforce.console.getFocusedSubtabId(setTabDirty);
9        };
10         function setTabDirty(result) {
11            sforce.console.setTabUnsavedChanges(true, displayResult, result.id);
12        };
13         function displayResult(result) {
14            if (result.success) {
15                 alert('Tab status has been successfully updated');
16             } else {
17                 alert('Tab status couldn’t be updated');
18             }
19        };
20    </script>
21</apex:page>

This example is only set to run if the Visualforce page is inside an application-level custom component. For more information, see Methods for Application-Level Custom Console Components.

Note

Response 

This method is asynchronous, so it returns its response in an object in a callback method. The response object contains the following field:

NameTypeDescription
successbooleantrue if returning the focused subtab ID was successful; false if if returning the focused subtab ID wasn’t successful.