1

I have added visualforce page in service cloud console app and the page developed with AngularJS. Facing an issue with to not getting the opened tab id in my angularJS page.

    <apex:page >
      <apex:includeScript value="/soap/ajax/26.0/connection.js"/>  
      <apex:includeScript value="/support/console/25.0/integration.js"/>
      <script type="text/javascript">

       window.onload = function (){
          sforce.console.getFocusedPrimaryTabObjectId(showTabId);
      }
      var currentTabId = '';
      var showTabId = function showTabId(result) {
          //Display the tab ID

          console.log('Tab ID1: ' + result.id);
          currentTabId = result.id;
      };

  </script>      


  <head>
    <meta charset="utf-8"></meta>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"></meta>

  </head>
  <body>
      <div  ng-app="myAngModuleName">
        <div >
          <div ng-view="ng-view"></div>
        </div>
      </div>
      <apex:includescript value="{!URLFOR($Resource.myAngStatic, 'scripts/lib.js')}"></apex:includescript>
      <apex:includescript value="{!URLFOR($Resource.myAngStatic, 'scripts/templates.js')}"></apex:includescript>
      <apex:includescript value="{!URLFOR($Resource.myAngStatic, 'scripts/main.js')}"></apex:includescript>


      <c:ngForce ></c:ngForce>

      <script type="text/javascript">
        var app = angular.module('myAngModuleName');

        app.factory('myFactory',function(){
                var currentPageId={
                  Id : currentTabId  ,
                };
                return currentPageId;
            });        

      </script> 
  </body>
</apex:page>

in above code I am trying to get selected tab id and passing those id to my angular module by using factory method.

But I am not getting the id, due to the getFocusedPrimaryTabObjectId() is the callback function. Its rendering the tab id after pageload

Please ask me if need any clarification on this and it very helpful if you have any solution for this...

Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.