• Rahul Sahay
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi All,

I'm working with the task related to closing tabs in service cloud console.
I handle actions when user close window or browser tab using this part of code:

 

<script type="text/javascript">
	var validNavigation = false;
 
        function wireUpEvents() {
        
        //get current url
        var linkUrl = window.location.href;

         var dont_confirm_leave = 1; //set dont_confirm_leave to 1 when you want the user to be able to leave withou confirmation
          var leave_message = 'You sure you want to leave page: '+ linkUrl +'?'
          function goodbye(e) {
          //alert(linkUrl);
            if (!validNavigation) {
              if (dont_confirm_leave!==0) {
                if(!e) e = window.event;
                //e.cancelBubble is supported by IE - this will kill the bubbling process.
                e.cancelBubble = true;
                e.returnValue = leave_message;
                //e.stopPropagation works in Firefox.
                if (e.stopPropagation) {
                  e.stopPropagation();
                  e.preventDefault();
                }
                //return works for Chrome and Safari
                return leave_message;
              }
            }
          }
          window.onbeforeunload=goodbye;
         
          // Attach the event keypress to exclude the F5 refresh
          jQuery(document).bind('keypress', function(e) {
            if (e.keyCode == 116){
              validNavigation = true;
            }
          });
         
          // Attach the event click for all links in the page
          jQuery("a").bind("click", function() {
            validNavigation = true;
          });
         
          // Attach the event submit for all forms in the page
          jQuery("form").bind("submit", function() {
            validNavigation = true;
          });
         
          // Attach the event click for all inputs in the page
          jQuery("input[type=submit]").bind("click", function() {
            validNavigation = true;
          });
         
        }
         
        // Wire up the events as soon as the DOM tree is ready
        jQuery(document).ready(function() {
          wireUpEvents();
        });
	 </script>  

 

But I have problems with closing tabs in service console. Any ideas how I can handle this?

 

Regards,

Lukasz

 

 

[EDIT]

We can do this invoking Service Cloud Console Method:

function tabUnsavedJS(){
           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');
             }
      }

 After this Salesforce will show warning message when user will close concole tab,