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
VirajViraj 

Call outside Visualforce page from a managed pack

Hi All,

 

I have created a managed pack. Its namespace is "myNSp"

 

I want this managed pack to call a Visualforce (VF) page given by the user (person who is going to use my managed pack) .

 

In the apex code I get the user's VF page from line given below

 

pdfPage = new pagereference('/apex/'+templateName);

 

When this code is executed the in the user's Salesforce organization, it say that the "Page does not exist".

 

I found out that when my managed pack is run in the user's organization it appends "myNSp" when calling the user's VF page. Since user's VF cannot have my namespace it give the  "URL does not exist".

 

Is there a way to the apex application get the true url to user's VF page ?

 

ie. if I use a code like below, is there a way to get value for 'usersUrlPart' variable ?

 

pdfPage = new pagereference('https//:'+usersUrlPart+'/apex/'+templateName);

 

 

Viraj

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
amar joshiamar joshi

u can call ur page like

pdfPage = new pagereference('/apex/'+yournamespace.templateName);