[SalesForce] Lookup field for Profile in Visualforce page

enter image description hereI want to create a VF page where I can render a lookup field to profile.

This is what I have done till now. AdminController is my Custom Controller

public with sharing class AdminController{

   public User user1 {get;set;}

   public AdminController(){

      user1=new User();

Now in VF page

<apex:inputField value="{!user1.Profile}" />

But I am getting Error :

Expression value does not resolve to a field Error is in expression
'{!user1.Profile}' in component in page

Best Answer

Unfortunately for the profile you wont be able access as a lookup as we all know there is no such field in salesforce thats lookup to profile

The alternative solution could be to roll your own custom lookup window as shown in below blog


OR just think of a new window open in javascript and pass the value from child window to the parent window .

Lets say i want to open a visualforce page(PageOpener) as a pop up window through a sample vf page named WindowOpenerTest

Code for the WindowOpenerTest(Parent page)

<apex:page id="page">
<apex:form id="theform">
    <script type="text/javascript">
             var newWin;

 function openWin(){
    var url="/apex/PageOpener";
    newWin=window.open(url, 'Popup','height=500,width=800,left=200,top=100');

 function parentalert(camp){
//alert('In parent Window<<<<<<<'+camp);

      <apex:inputText id="hello" onclick="openWin();" />

Code for the child window(PageOpener) and script for the communication from child to parent window

<apex:page sidebar="false" showHeader="false">

<apex:form >
    <!-- Begin Default Content REMOVE THIS -->
            This is your new Page
            <!-- End Default Content REMOVE THIS -->

    <apex:outputLink id="theLink"
        onclick="sendPopUpValues('{!$User.Alias}')" styleClass="p"> Link

    <script type="text/javascript">
         function sendPopUpValues(camp){//sending user Alias to the parent window through script


The above code should get you started and help you on how to send values between parent and child windows.

Related Topic