Sets the unsaved changes icon (
) on subtabs to indicate unsaved data. This method is only available in API version 23.0 or later.
Syntax
sforce.console.setTabUnsavedChanges(unsaved:Boolean, callback:Function, (optional)subtabId:String)
Arguments
| Name | Type | Description |
|---|---|---|
unsaved |
boolean | If true, the tab is marked as having unsaved changes. |
callback |
function | JavaScript method that’s called upon completion of the method. |
subtabId |
string | The 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
<!-- otherprops: set_clipboard --><apex:page standardController="Case">
<A HREF="#" onClick="testSetTabUnsavedChanges();return false">
Click here to indicate this tab has unsaved changes</A>
<apex:includeScript value="/support/console/68.0/integration.js"/>
<script type="text/javascript">
function testSetTabUnsavedChanges() {
sforce.console.setTabUnsavedChanges(true, displayResult);
};
function displayResult(result) {
if (result.success) {
alert('Tab status has been successfully updated');
} else {
alert('Tab status couldn’t be updated');
}
}
</script>
</apex:page>
note: 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.
Response
This method returns its response in an object in a callback method. The response object contains the following field:
| Name | Type | Description |
|---|---|---|
success |
boolean | true if update was successful; false if update wasn't successful. |
Sample Code API Version 25.0 or Later–Visualforce
<!-- otherprops: set_clipboard --><apex:page standardController="Case">
<A HREF="#" onClick="testSetTabUnsavedChanges();return false">
Click here to indicate this tab has unsaved changes</A>
<apex:includeScript value="/support/console/25.0/integration.js"/>
<script type="text/javascript">
function testSetTabUnsavedChanges() {
sforce.console.getFocusedSubtabId(setTabDirty);
};
function setTabDirty(result) {
sforce.console.setTabUnsavedChanges(true, displayResult, result.id);
};
function displayResult(result) {
if (result.success) {
alert('Tab status has been successfully updated');
} else {
alert('Tab status couldn’t be updated');
}
};
</script>
</apex:page>
note: 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.
Response
This method is asynchronous, so it returns its response in an object in a callback method. The response object contains the following field:
| Name | Type | Description |
|---|---|---|
success |
boolean | true if returning the focused subtab ID was successful; false if if returning the focused subtab ID wasn't successful. |