+ Start a Discussion
Mahesh Tandan 6Mahesh Tandan 6 

Button constent source URL call to vf page

Hello Sr. developers

Can someone tell me how can I pass Id with visualforce page
I'm calling a visualforce page with constent source URL , I know I can choose the visualforce page but I want to pass the Id
below is my code

visualforce page
<apex:page standardController="Campaign" extensions="OnLoadController" action="{!open_Donation_Site}" />

Extension
 
public class OnLoadController {
    Site subdomain;
    public OnLoadController(apexPages.StandardController con){}
    public String open_Donation_Site(){
        subdomain = [SELECT Subdomain FROM Site limit 1];
        Organization apt = [SELECT InstanceName FROM Organization];
        return 'https://'+subdomain.Subdomain+'.'+apt.InstanceName+'.force.com/CampaignPayment?id=';
    }
}
Actully I'm creating a managed pack that's why I want to fetch dynamically site domain name from different orgs.

my button
User-added image

It's saving but when I click button it gives error that page not found, but if i remove {!Campaign.Id} it works

I want to give visualforce page name and then Campaign.Id
Best Answer chosen by Mahesh Tandan 6
Jakub Kołodziej 7Jakub Kołodziej 7
Try:
/apex/Nuclay__open_in_site?id={!Campaign.Id}

All Answers

Jakub Kołodziej 7Jakub Kołodziej 7
So are you trying to pass id from url to controller?
Jakub Kołodziej 7Jakub Kołodziej 7
Try:
/apex/Nuclay__open_in_site?id={!Campaign.Id}
This was selected as the best answer
Mahesh Tandan 6Mahesh Tandan 6
Thank you jakub kolodziej 7 for replay

Yes I solved this issue with same code