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
arishi0arishi0 

How to pass variable value into an apex class

Hello,

 

I have a visualforce page exposed in a force.com site. This site is open to the public and guests should be able to access this page through my clients website, a link there would take them to my site. What I need is to pass an IDcode through that link so that when the visualforce page is shown it will have the code in its controller.

 

The idea is that the page is access by many of my clients and each has their own code, this is important so that when creating the controller class I will be using this "Idcode"  to fetch some of the clients data such as rates and availability.

 

How can I do this???

Best Answer chosen by Admin (Salesforce Developers) 
Pat PattersonPat Patterson

Hi arishi0,

 

You can pass URL parameters into Visualforce pages (whether or not they are on a site) thus:

 

http://example-developer-edition.na3.force.com/?IDcode=1234

You can then access that parameter from your page controller with:

 

System.currentPageReference().getParameters().get('IDcode');

 

Note that, if you have no other security in place, you should make the 'IDcode' values long and difficult to guess, otherwise your clients will be able to see each other's rates by simply iterating through IDcodes 1, 2, 3, 4...

 

Cheers,

 

Pat

All Answers

Pat PattersonPat Patterson

Hi arishi0,

 

You can pass URL parameters into Visualforce pages (whether or not they are on a site) thus:

 

http://example-developer-edition.na3.force.com/?IDcode=1234

You can then access that parameter from your page controller with:

 

System.currentPageReference().getParameters().get('IDcode');

 

Note that, if you have no other security in place, you should make the 'IDcode' values long and difficult to guess, otherwise your clients will be able to see each other's rates by simply iterating through IDcodes 1, 2, 3, 4...

 

Cheers,

 

Pat

This was selected as the best answer
arishi0arishi0

Thanks Pat!!! It did work, I had a hunch this is how I would go around doing it and in fact it is that way. GReat advice on creating large IDcodes, will certainly do that.

 

Thanks again!