1

I have a app-level custom component module (the ones in the footer) for a service cloud application. I need to open up a Primary Tab in the console from this custom component.

I have the Id of the Account that I want to open the primary tab for but I am running into issues because the component seems to be a child window of the main console. This is giving me the following issues:

sforce.console.openPrimaryTab(accountId, "/ui/support/servicedesk/ServiceDeskPage", true);

The above code doesn't work (nothing happens at all), I think because there is no console in the child window. I need to reach the console window via window.parent.

window.parent.location.replace('/' + accountId);

This actually works, but it opens the record in the standard sales cloud view rather than in the service cloud.

I have also tried:

window.parent.sforce.console.openPrimaryTab(accountId, "/ui/support/servicedesk/ServiceDeskPage", true);

but I get a Permission denied to access property sforce error

Is there any way I can open a tab from the component?

Also, I am confused as to the second parameter of the openPrimaryTab method (the url). I am assuming that it requires the url of the console.

Many thanks in advance

Edit

Looking at chrome's console readout, I see that I'm getting the following error:

Unsafe JavaScript attempt to access frame with URL [salesforce console domain] from frame with URL [visualforce domain e.g. https://c.xxx.visual.force.com/etc] Domains, protocols and ports must match.

From the article linked to in @techtrekkers comment:

Visualforce pages don’t have access to the srcUp() method, and hence need the Service Cloud Integration Toolkit methods to open new subtabs/ primary tabs.

  • 1
    Have you tried the srcUp function success.salesforce.com/ideaView?id=08730000000YKxYAAW – techtrekker Dec 3 '12 at 15:47
  • Hi techtrekker. I had a read of that article, thanks. It notes that "Visualforce pages don’t have access to the srcUp method, and hence need the Service Cloud Integration Toolkit methods to open new subtabs/ primary tabs." The custom component has to be a VForce page, so it seems that the error is caused by an attempt to access a frame from one url (the salesforce url) from a different url (the VForce one). I will update my question to include this info. – Joe Dec 3 '12 at 17:57
1

I managed to launch a Primary Tab from a Custom Console Component, using this openPrimaryTab sample page as the Custom Console Component.

I had to whitelist the domain that I wanted to launch, so in this case www.salesforce.com in the Service Console App Settings (Whitelist domains)

The Primary Tab does launch alright, although the cross domain error message that you mentioned comes up in the javascript console, I would guess because Visualforce is served up from a different domain.

  • Thanks for your post @techtrekker. I got this example to work once I added the domain to the whitelist as you suggested. Just need to apply this to my other component hopefully. – Joe Dec 4 '12 at 18:47
  • Thank you both, @techtrekker and @Joe; great topic and conversation. I'm having the same requirement, but I'm not seeing any resolution for the cross domain error. I'm going to read into the cross domain post referenced in the answer once I have some more time. At the moment, I'm able to get the primary tab to open but no content displays and the console I'm getting the cross-origin error. I'm also seeing some parameters following the intended url - is that supposed to happen? – zainogj May 11 '15 at 18:26
1

in your Advanced User Details de-select the below options

-Development Mode -Show View State in Development Mode

I went through same issue as you the above solved my issue, because when you enable those options the VF page is in an extra iframe which causes this.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.