1

I want to redirect user to a VF Page from a managed Package UI where code is written in Angular JS,

<div class="slds-no-flex">
    <span><button class="slds-button slds-button" onclick="redirectToMap();" id="Btn" value="{{a.id}}">View Map</button></span>

JS

 function redirectToMap() {

sforce.console.getEnclosingPrimaryTabId(openSubtab);
sforce.console.getFocusedSubtabId(closeSubtab);


}

var closeSubtab = function closeSubtab(result) {

var tabId = result.id;
sforce.console.closeTab(tabId);

  };

var openSubtab = function openSubtab(result) {

var parentID = document.getElementById("Btn").value;
var primaryTabId = result.id;
sforce.console.openSubtab(primaryTabId ,'/apex/AccountDisplayVF?id=' + parentID, 
true, 'New Map', null);
};

This isn't working . Anything I am missing?

3
  • 3
    have you tried '/apex/c__AccountDisplayVF' (assuming that page is unmanaged)? Jun 13, 2017 at 17:14
  • 1
    Are you in the console UI? The code you posted looks like it would only work there. Jun 13, 2017 at 17:47
  • I'll write up a brief answer for posterity Jun 14, 2017 at 17:18

2 Answers 2

3

The issue here is that when you're opening an unmanaged page from a Managed package, the platform is assuming the namespace of the managed package should also prefix your Visualforce page.

So, for example, if you have a Visualforce page in the NS namespace, and then put a button on that page that navigates to an unmanaged page, the platform would assume that you wanted NS__MyPage instead of just MyPage. To prevent this, you can qualify your Page with the local (c) namespace, so in your case:

/apex/c__AccountDisplayVF
5

Always use $Page global variable for redirection in a visualforce page.

$Page.PageName if its outside namespace.

or $Page.Namespace__PageName, if its inside.


For accessing $Page in JavaScript placed inside a static resource, use:

  1. a global variable

  2. some design pattern to avoid a global variable as mention in this blog.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .