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
InfantInfant 

Visualforce Page

Hi,

 

I created a VisualForce Page which i attached to a custom tab. Now under the visualforce page i wrong a custom controller, the section of the code pasted below.

 

public string getInstallBase()
    {
        string x= ApexPages.currentPage().getParameters().get('id');
        return  x + 'Hi Dear';
    }

Now when i am displaying the the value x, in the page, it is showing NULL. I tried using other two commands instead of ApexPages.CurrentPage...... (used s.getRecord().id & system.currentPageReference().getParameters()..... where 's' is the standard controller) but found the value x as NULL), can somebody help, wht is the problem or how to derive the id.

Rajesh ShahRajesh Shah
How are you displaying the value on the page? Is InstallBase a controller variable?
InfantInfant

Pls find the Visualforce Page CODE below:

 

<apex:page Controller="<ControllerName>'

<p>{!Installbase}</p> // this should print the id value..... 

 

 

Rajesh ShahRajesh Shah
Is the variable public? And what happens if you just return 'Hi Dear' from the controller method instead of x + 'Hi Dear'?
InfantInfant

yes it is a public method, and in the page out HI DEAR is coming preceded by null. I tried checking the value of x in the method itself and put a logic if x is null then initialise it with 'TEST FAILED'.

 

in the output i got TEST FAILED HI DEAR.

bob_buzzardbob_buzzard

You won't be able to access the record from the standard controller using the page as described, as you have a custom controller that isn't an extension controller.

 

When you click on the tab to go to this page, what is the URL that the browser goes to?  If the URL doesn't have the following string '?id=' followed by an id, then the result retrieved from the current page parameters will indeed be null.

InfantInfant

thnx bob u r write, the URL doesn;t displays / contains the id, it only gives me the name of the tab. but what is the solution for my issue.

 

i basically wanted to created a custom controller, where from i want to pick up values (using methods) from different objects based on the user who logins in ( i don;t mean profile, basically like if a transaction is related to an account, i want to pick those related data to display)

bob_buzzardbob_buzzard

You can find out the SalesForce ID of the currently logged in user in your controller as follows:

 

UserInfo.getUserID();

 

Once you have this, you can look up whatever you are interested in via SOQL.

InfantInfant
thanks a ton bob, can i hv ur e-mail id or chat id plsss, provided u can share.
bob_buzzardbob_buzzard
Its better to post up on the discussion boards - that way we all learn.