+ Start a Discussion
Abc234Abc234 

Getting error on

pageReference pr = new pageReference('/apex/Homepage?uid ='+ listusers[0].id);

pr.setredirect(true);

return pr;

when i use above code am getting error

 

LoginController Compile Error: line 37:81 no viable alternative at character '' at line 37 column 81

 

 So i tried with getparameters still am getting run time error

 

PageReference pr= page.Homepage;
pr.getParameters().put('id',listusers[0].id);

pr.setredirect(true);

return pr;

 

Visualforce Error

Id value a099000000AWn0l is not valid for the Movie__c standard controller

 

How to use ID that i passed through getparameters, in Movie page

 

I just need to display like hello Name

 

Can anyone help me in this

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

I'm guessing that the HomePage uses the Movie__c standard controller - that being the case you will need to use a different parameter name than 'id', as the standard controller will interpret that as the id of the record that you want to manage.

 

Should be as simple as:

 

PageReference pr= page.Homepage;
pr.getParameters().put('uid',listusers[0].id);
pr.setredirect(true);
return pr;

 You can then retrieve this value in an extension controller and extract the user information that you need. 

 

However, you can also get at information about the logged in user via the $User global variable, eg.

 

{!$User.FirstName} {!$User.LastName}

so if its a logged in user rather than a selected user, you don't need parameters etc.