• Sandy Cook 1
  • NEWBIE
  • 0 Points
  • Member since 2017

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

Hi,

I've got a Custom Visualforce page which is attempting to open a tab from a link.

I'm using the standard exmaple code from https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_opensubtab.htm

However there are zero tabIDs coming back from the page so opening a new tab fails. Code looks like

<apex:column ><A HREF="#" onClick="testOpenSubtab();return false">Click here to open a new subtab</A> </apex:column>


<apex:includeScript value="/support/console/42.0/integration.js"/>
    <script type="text/javascript">
        function testOpenSubtab() {
            //First find the ID of the primary tab to put the new subtab in
            console.log(sforce.console.getFocusedPrimaryTabId(showTabId));
            if(sforce.console.isInConsole()){
                    sforce.console.getEnclosingPrimaryTabId(openSubtab);
            } else {
                   console.log('we are not in console');
                }

        }
        var showTabId = function showTabId(result) {

            //Display the primary tab IDs
            
            console.log('1');    
            console.log(result.ids);
            console.log('2'); 

            };

        
        var openSubtab = function openSubtab(result) {
            //Now that we have the primary tab ID, we can open a new subtab in it
            var primaryTabId = result.id;
            console.log("primaryid" + primaryTabId);
            console.log(result);
            sforce.console.openSubtab(primaryTabId , 'http://www.salesforce.com', false, 
                'salesforce', null, openSuccess, 'salesforceSubtab');
        };
        
        var openSuccess = function openSuccess(result) {
            //Report whether we succeeded in opening the subtab
            console.log(result);
            if (result.success == true) {
                alert('subtab successfully opened');
            } else {
                alert('subtab cannot be opened');
            }
        };
    </script>


The resulting console output is.

User-added image
Come someone point out what I'm missing / doing wrong here? 
Many thanks.

Hi, First question so go easy on me.

We are using live agent.
After a Live agent interaction we want to ask a few survey questions.
I set up Surveyforce and have the survey being viewed and answers being save.
However would like to also save the caseID and agentID to the results.

The object <SurveyTaker> has the attributes <User_c> and <Case__c>.
I've added a div tag to the TakeSurvey visualforce page and can output the JSON with these elements (in order to convince myself they were there!) This works.
 
<div id="passInDataToSurvey"> 
Chat Details: <apex:outputText value="{!$CurrentPage.parameters.chatDetails}" />
Attached Records : <apex:outputText value="{!$CurrentPage.parameters.attachedRecords}" />
</div>
So I have my JSON. I want to parse that and pass through the attributes. Something like... (probably not the way to do it...)
<script> 
var getUser = JSON.parse({!$CurrentPage.parameters.chatDetails}); 
document.getElementById("User__c").innerHTML = getUser.agent.userId; 
</script> 

<apex:inputHidden value="{!User__c}" id="User__c"/>

But when I save the visualforce page I get the error Unknown property 'Survey__cStandardController.User__c' as the User__c attribute is on <SurveyTaker> not <Survey__c>

Would be awesome if anyone could help,

Cheers

Hi,

I've got a Custom Visualforce page which is attempting to open a tab from a link.

I'm using the standard exmaple code from https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_opensubtab.htm

However there are zero tabIDs coming back from the page so opening a new tab fails. Code looks like

<apex:column ><A HREF="#" onClick="testOpenSubtab();return false">Click here to open a new subtab</A> </apex:column>


<apex:includeScript value="/support/console/42.0/integration.js"/>
    <script type="text/javascript">
        function testOpenSubtab() {
            //First find the ID of the primary tab to put the new subtab in
            console.log(sforce.console.getFocusedPrimaryTabId(showTabId));
            if(sforce.console.isInConsole()){
                    sforce.console.getEnclosingPrimaryTabId(openSubtab);
            } else {
                   console.log('we are not in console');
                }

        }
        var showTabId = function showTabId(result) {

            //Display the primary tab IDs
            
            console.log('1');    
            console.log(result.ids);
            console.log('2'); 

            };

        
        var openSubtab = function openSubtab(result) {
            //Now that we have the primary tab ID, we can open a new subtab in it
            var primaryTabId = result.id;
            console.log("primaryid" + primaryTabId);
            console.log(result);
            sforce.console.openSubtab(primaryTabId , 'http://www.salesforce.com', false, 
                'salesforce', null, openSuccess, 'salesforceSubtab');
        };
        
        var openSuccess = function openSuccess(result) {
            //Report whether we succeeded in opening the subtab
            console.log(result);
            if (result.success == true) {
                alert('subtab successfully opened');
            } else {
                alert('subtab cannot be opened');
            }
        };
    </script>


The resulting console output is.

User-added image
Come someone point out what I'm missing / doing wrong here? 
Many thanks.