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
sid_devsid_dev 

Get value from a visual force page into an extension

Hi,

 

I have a visual force page which has an input field of type heirarchy(so it's like lookup of users). I have a command button which calls an action written in the extension for the standard controller.

 

In the following code my userObj is empty and doesn't have any value. I am not sure what is wrong. I have a seperate save methos/action for the command button to update the userobject for the value selected.

 

                        public MyExtensionController(ApexPages.StandardController stdController)
                        {       
                                   try
                                   {
                                                //get the values from input field
                                                this.userObj = (User)stdController.getRecord();

                                    }

                                     catch(System.Exception e)

                                    {

                                                system.debug(e);

                                    }

                        }

              

Any insight will be helpful

 

Thanks

Sid_dev                                                         

bob_buzzardbob_buzzard

How are you retrieving the page (i.e. what URL).

 

If you want the user details to be populated in the standard controller, you'll need to pass the id of the user as a parameter of the form 'MyApexPage?id=<theuserid>'.

sid_devsid_dev

URl - /apex/Mypage

 

Well I am accessing the User object to update the supervisors information which is a heirarchy field. So it shows a lookup window when the user tried to select a user. Basically I am trying to update a user's supervisor which is again a user. I don't want to pass any querystring parameters here. Secondly I getting cxurrent user id by saying UserInfo.getuserid()

 

bob_buzzardbob_buzzard

You may be getting the current user by saying UserInfo.getUserId(), but the following code in your controller:

 

this.userObj = (User)stdController.getRecord();

 

Is looking for the User object from the standard controller, which will only be populated if you pass an id to the query string.

 

If you are getting the user through another mechanism, why do you need to access the standard controller? 

sid_devsid_dev

Hi,

 

OK the mistake I was doing is I didn't write the getter method. It works for me now.

 

Thanks,
Sid_dev