You need to sign in to do that
Don't have an account?

Lookup field in VisualForce page
Hi,
I have a visualforce page which has a UserRole field which needs to be lookup.
However, I am using custom controller for same. Can you please let me know how can I display lookup field for same in my visualforce page?
Thanks,
Vimal
Edwin is right. UserRole object does not automatically allow look-up to be shown. And in my case, I am using Custom Controller anyhow.
I went through some community posts similar to mine and found some solutions.
But I too found a simple, less time consuming solution which worked for me!
I added this part in my controller and page code and it worked for me!
public TerritoryUsersController()
{
stdTerritoryId = ApexPages.currentPage().getParameters().get('stdTerritoryId');
System.debug('Territory Id-------------->'+stdTerritoryId);
usr = new User();
usr.UserRoleId = null;
init();
}
In page,
<apex:outputLabel value="Role" /> <apex:inputfield value="{!usr.UserRoleId}"/>
All Answers
Edwin is right. UserRole object does not automatically allow look-up to be shown. And in my case, I am using Custom Controller anyhow.
I went through some community posts similar to mine and found some solutions.
But I too found a simple, less time consuming solution which worked for me!
I added this part in my controller and page code and it worked for me!
public TerritoryUsersController()
{
stdTerritoryId = ApexPages.currentPage().getParameters().get('stdTerritoryId');
System.debug('Territory Id-------------->'+stdTerritoryId);
usr = new User();
usr.UserRoleId = null;
init();
}
In page,
<apex:outputLabel value="Role" /> <apex:inputfield value="{!usr.UserRoleId}"/>