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
Dave CraigmileDave Craigmile 

Instantiating a NON-PACKAGED Visualforce page from WITHIN a Package

Help! I have code (shown below) that tries to instantiate a Visualforce page whose name is stored in a table column (known only at runtime, say, "MyCustomPage").

The page to be instantiated is NOT in our managed package, but the code trying to instantiate it IS in our managed package.

The Salesforce runtime appends our namespace to the name and thus the page cannot be found or instantiated. How can I get the runtime to butt out and not try to rename my page URL string?

(1) The managed package code that creates the page reference:

public PageReference getPageReference(Id documentOptionsId) {

TMSDocumentOverride__c over = DB.getTMSDocumentOverride(documentOptionsId, this.getId());
    if(over != null && over.Page_Override__c != null) {
        return new PageReference('/apex/' + over.Page_Override__c);
    } 
etc...

(2) I want "return new PageReference('/apex/' + over.Page_Override__c);" to return a PageReference pointing to /apex/MyCustomPage

(3) Instead, it tries to instantiate "/apex/rtms__MyCustomPage" where "rtms__" is my package namespace. Ugh.

How do I get the runtime to leave my URL alone so it instantiates /apex/MyCustomPage NOT /apex/rtms__MyCustomPage??

Thanks!