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
Saran KumarSaran Kumar 

VF page - Custom lookup field(Account) - Clicked - Auto populate Users to Custom lookup field

Hi all,

      I am new to Salesforce. I have created a Custom Visual force Page in which We have two Custom Fields( Lookup + Picklist). when i  Select the Account from the lookup Field, The Corresponding Users on the selected account should get Autopopulated in the nearby Picklist field.

   Kindly share your ideas and Sample Codes if any....Thanks in Advance..

Regards,

Saran

      

Bhawani SharmaBhawani Sharma

Saran Kumar wrote:

Hi all,

      I am new to Salesforce. I have created a Custom Visual force Page in which We have two Custom Fields( Lookup + Picklist). when i  Select the Account from the lookup Field, The Corresponding Users on the selected account should get Autopopulated in the nearby Picklist field.

   Kindly share your ideas and Sample Codes if any....Thanks in Advance..

Regards,

Saran

      



You need to create a method in controller class. This method will fetch the users based on selected account.

You need to use onblur event on your lookup field. This onBlur will call a action function and action function will call controller class's method. You will have to reRender picklist field using reRender attribute. Like 

 

<apex:actionFunction name="gteUsers" action="{!getUsers}" reRender="outputPanel" />

<apex:outputPanel id="outputPanel">
    <apex:inputField value="{!object.Lookup_Field}" onblur="getUsers();" />
    <apex:inputField value="{!object.Picklist_Field}" />
</apex:outputPanel>

Controller
-----------------------------
public void getUsers() {
//code
}

 

 

Saran KumarSaran Kumar
Thank you...but my criteria is to create these lookup and Picklist field in a VF page Which should be created via Coding. Lookup field should Get the accounts and Once i select the account it should auto populate the relevant Contacts(users) Associated to that selected Account.
Kindly Share your Views and Coding samples...
Regards,
Saran
Bhawani SharmaBhawani Sharma
For the custom lookup, you can go with teh Jeff's blog:
http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/

Picklist part will work as I suggested above. Unfortunately I do not have sample code.
Saran KumarSaran Kumar
Thanks a lot for your immediate response...Will try the link and get back soon...
regards,
Saran