function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Erite11Erite11 

Issue with javascript button within Service Console need advice please

I am trying to implement the service console and am stuck on a button issue.

 

Currently  I have a custom "New Case" button that displays within a contact.  It uses javascript to auto-pop some fields based on user settings

Ex:

window.parent.location.href ="%2F500%2Fe?00N800000034wTE={!$User.Language_Support__c}&cas3_lkid={!Contact.Id}&00N80000003MDbe={!$User.Default_Country_cases__c}&retURL=%2F500%2Fo";

 

In testing within the console, this will load the case creation form outside the console.  To get around this, I am using the following code (some hard coding in place right now to eliminate variables):

 

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")} 
if (typeof(srcUp) == 'function') 
{
} else {    
     window.parent.location.href ="%2F500%2Fe?00N800000034wTE={!$User.Language_Support__c}&cas3_lkid={!Contact.Id}&00N80000003MDbe={!$User.Default_Country_cases__c}&retURL=%2F500%2Fo";
}
Now the behavior is working in console (as well as if not in console), however I believe that because the button originates from a "Contact" page, that somehow the controller class is not changing to a case controller.  Even though the main page is laid out correctly, I am not getting the Knowledge or other side bars that should be there (getting contact one still).
Any suggestions on how to fix this, or a more elegant way of doing this would be appreciated.  The built in "New Case" works fine, but I need to pass some $user parameters into case fields during submission, all while remaining within console.

 

Best Answer chosen by Admin (Salesforce Developers) 
sfdcAnonsfdcAnon

Hmmm. "External" means that the console hasn't recognized the page as a salesforce or case page, which is why the knowledge sidebar is now showing.

 

For the srcUp target url, can you try the following -

 

/500/e?00N800000034wTE={!$User.Language_Support__c}&cas3_lkid={!Contact.Id}&00N80000003MDbe={!$User.Default_Country_cases__c}

 

and also just

 

/500/e?

 

I want to ensure that it's not just the url that makes the console think that it's not a case page.

All Answers

sfdcAnonsfdcAnon

Hi Erite11,

 

When you use srcUp, is a new subtab being created?Or is the existing subtab navigating to the new case page?

 

The knowledge sidebar and case custom components should load.

 

Can you also try the "srcSelf" method? Just use the exact same call, just change the method name from srcSelf to srcUp.Curious to know what the result is in that case.

 

 

Erite11Erite11

Using SrcSelf is loading within the current frame and subtab, however it is leaving other subtabs around ti tied to the Contact Object page layout (still has a left panel from contact).  This behavior does not update upon case save, and if you refresh the subtab, it goes back to contact view.

 

Using SrcUp, I get a new subtab on same level referenced as "external" instead of correct case info.  Upon saving a case in this tab, I do not get anything that should be present on a case view (Knowledge panel etc), and am in fact taken out of a console view entirely.

sfdcAnonsfdcAnon

Hmmm. "External" means that the console hasn't recognized the page as a salesforce or case page, which is why the knowledge sidebar is now showing.

 

For the srcUp target url, can you try the following -

 

/500/e?00N800000034wTE={!$User.Language_Support__c}&cas3_lkid={!Contact.Id}&00N80000003MDbe={!$User.Default_Country_cases__c}

 

and also just

 

/500/e?

 

I want to ensure that it's not just the url that makes the console think that it's not a case page.

This was selected as the best answer
Erite11Erite11

Figured it out, thanks to your suggestion!  Many thanks, and for anyone else in need, here is what was done.

Taking 

 

 

 

sfdcAnonsfdcAnon

Great! Happy to help.

DevelopersDevelopers

Hi,

 

I am also facing the same issue. In my project, we developed one visual force page and added to the orders (Orders__c) custom object. In that VF Page, we used to custom buttons called as New case for creating the new case in SFDC.

 

When the user clicks on the New Case custom button, the corresponding action method will invoke and as a result it redirects to the case creation screen.

 

Here, when we are working in Service Console, when the user clicks the new case button from the order detail page, it redirects to the sales screen. But, we want to open the new case screen in service console as a sub tab.

 

I used javascript function srcUP() in that VF Page.

 

 <script type="text/javascript">
             function openNewCaseInSubTab(){             
              srcUp("/500c0000001xoHA?"); here, i hardcoded the value for testing purpose.
              }
        </script>

 

But, iam not getting the sub tab for created case.

 

Can you please check and support me to fix this issue.

 

Thanks in advance.

 

Regards,

kumar

sfdcAnonsfdcAnon

Hi Kumar,

 

If you are on a visualforce page, there's no need to use srcUp. Just use the Service Cloud Console Integration Toolkit. srcUp is not supported in Visualforce.

 

So in the button JS, put the following
{!REQUIRESCRIPT("/support/console/27.0/integration.js")}
sforce.console.openSubtab(..url, subtabnamehere);

Put the name of the subtab in the directly into the open subtab call.

DevelopersDevelopers

Hi

JimRaeJimRae

You have an error in your URL that is causing the problem.

 

You have:

var URLValue = "https://c.cs14.salesforce.com/ui/support/servicedesk/ServiceDeskPage"+{!NewCaseId}+"?isdtp=vw";

 which is missing a # and a / 

 

Should be

 

var URLValue = "https://c.cs14.salesforce.com/ui/support/servicedesk/ServiceDeskPage#/"+{!NewCaseId}+"?isdtp=vw";

 Give that a try!!

ve krve kr
Is it possible to closing the subtab and rediredt to the home console  by click the custom button using Srcup.
Rajesh Admin 9Rajesh Admin 9
I am trying to use the srcUp method in serviceConsole for opening the URL in a new tab(As openSubtab is not working my scenario is onClick of Dropdown value control needs to be diverted to other page) but i am getting an error like 'Uncaught ReferenceError: srcRef is not defined' seems to be some javaScript files are missing. I included both connetion.js and integration.js files in my VF page in the same order. Am i missing something help here would be very thansfull.

<apex:includeScript value="/soap/ajax/26.0/connection.js"/> 
    <apex:includeScript value="/support/console/31.0/integration.js" />