<apex:page >
<html>
<head>
<title>Disable close Tab on Load</title>
<!-- Service Console integration API library -->
<script src="/support/console/44.0/integration.js"></script>
<!-- Callback functions to handle tab events -->
<script type="text/javascript">
function displayResultsCallback(result){
var resDiv = document.getElementById("eventResults");
resDiv.innerHTML = JSON.stringify(result);
}
// For use within a tab's sidebar (you don't need tab ID)
function testDisableTabCloseTrueWithoutId() {
sforce.console.disableTabClose(true, false, displayResultsCallback);
}
function testDisableTabCloseFalseWithoutId() {
sforce.console.disableTabClose(false, false, displayResultsCallback);
}
// For use anywhere (you need the tab ID)
// Note: Your tab ID might be different than the one used here.
// You can get the tab ID many different ways,
// including sforce.console.getEnclosingTabId().
// See the documentation for details.
function testDisableTabCloseTrueWithId() {
var tabId = window.prompt("Enter the tab ID","scc-pt-0");
sforce.console.disableTabClose(true, tabId, displayResultsCallback);
}
function testDisableTabCloseFalseWithId() {
var tabId = window.prompt("Enter the tab ID","scc-pt-0");
sforce.console.disableTabClose(false, tabId, displayResultsCallback);
}
</script>
</head>
<body>
<h1>Disable Tab Close Examples</h1>
<br/><br/>
<h2>API Callback Result</h2>
<br/>
<code><div id="eventResults" /></code>
<br/>
<h2>With No Tab ID</h2>
<p>The tab ID will be auto-detected by context, or the event will fail.</p>
<ul>
<li><a href="#" onClick="testDisableTabCloseTrueWithoutId();return false;">
Disable closing for the enclosing tab</a></li>
<li><a href="#" onClick="testDisableTabCloseFalseWithoutId();return false;">
Re-enable closing for the enclosing tab</a></li>
</ul>
<h2>With Tab ID Provided</h2>
<p>When the event context doesn't have a detectable tab ID, you can
supply it yourself.</p>
<ul>
<li><a href="#" onClick="testDisableTabCloseTrueWithId();return false;">
Disable closing for a specific tab (via tab ID)</a></li>
<li><a href="#" onClick="testDisableTabCloseFalseWithId();return false;">
Re-enable closing for a specific tab (via tab ID)</a></li>
</ul>
</body>
</html>
</apex:page>
I trust you are doing very well.
Please refer to the below doc which might help you further with the above issue.
https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_disabletabclose.htm
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas
Classic code
Lightning code
https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_lightning_disableTabClose.htm?search_text=Close
Based on the Visibility rules it will execute and disable the tab
Did you add this one to the lilghtninf record page ??
Can you see console logs what is coming ..?
Yes.
No. How can I see those logs?