+ Start a Discussion
Deepak Pandey 13Deepak Pandey 13 

list of user is blank

apex class---
public class roleexten {
public Case cse {get; set;}
public String selectedId {get;set;}
public List<selectoption> UserOptionList{get;set;}
    
    public roleexten(ApexPages.StandardController controller)
     {
       cse  =new Case ();
     }
  public pagereference assignowner()
  {
  return page.vfpageownerassign ;
  }
  public void selected()
    
    {
       UserOptionList = new List<selectoption>();
       UserOptionList.add(new selectoption('','--None--'));
        
       for(User u :[select id ,name from user ])
            {
            system.debug('@@@@u' +u);
                  UserOptionList .add(new SelectOption(u.Id , u.Name));
                  
                }
                system.debug('@@@@UserOptionList' +UserOptionList );
           }
  
}

vf pages-

<apex:page standardController="Case" extensions="roleexten" sidebar="false">
 <apex:form >
  <apex:pageblock >
   <apex:pageBlockSection >
    <apex:pageBlockSectionItem >
     <apex:inputField value="{!cse.ownerId}"/>
     <apex:actionSupport action="{!selected}" event="onchange" reRender="cont"/> 
    </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
   
            <apex:outputPanel id="cont">
           <apex:pageblockSection title="Owner" >
                  <apex:selectList value="{!selectedId }">
                      <apex:selectOptions value="{!UserOptionList }"></apex:selectOptions>
                  </apex:selectList>
           </apex:pageBlockSection>
           </apex:outputPanel>
 

  </apex:pageblock>
 </apex:form>
</apex:page>
Best Answer chosen by Deepak Pandey 13
Amit Chaudhary 8Amit Chaudhary 8
Please updated your apex class like below
public class roleexten 
{
		public Case cse {get; set;}
		public String selectedId {get;set;}
		public List<selectoption> UserOptionList{get;set;}

		public roleexten(ApexPages.StandardController controller)
		{
			cse  =new Case ();
			selected();
		}
		public pagereference assignowner()
		{
			return page.vfpageownerassign ;
		}
		
		public void selected()
		{
			UserOptionList = new List<selectoption>();
			UserOptionList.add(new selectoption('','--None--'));

			for(User u :[select id ,name from user ])
			{
				system.debug('@@@@u' +u);
			    UserOptionList.add(new SelectOption(u.Id , u.Name));
			}
			system.debug('@@@@UserOptionList' +UserOptionList );
		}
  
}
Let us know if this will help you

 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Please updated your apex class like below
public class roleexten 
{
		public Case cse {get; set;}
		public String selectedId {get;set;}
		public List<selectoption> UserOptionList{get;set;}

		public roleexten(ApexPages.StandardController controller)
		{
			cse  =new Case ();
			selected();
		}
		public pagereference assignowner()
		{
			return page.vfpageownerassign ;
		}
		
		public void selected()
		{
			UserOptionList = new List<selectoption>();
			UserOptionList.add(new selectoption('','--None--'));

			for(User u :[select id ,name from user ])
			{
				system.debug('@@@@u' +u);
			    UserOptionList.add(new SelectOption(u.Id , u.Name));
			}
			system.debug('@@@@UserOptionList' +UserOptionList );
		}
  
}
Let us know if this will help you

 
This was selected as the best answer
Deepak Pandey 13Deepak Pandey 13
thanks sir but if i want add queue also in this  picklist ?
Amit Chaudhary 8Amit Chaudhary 8
That will better create new picklist
Deepak Pandey 13Deepak Pandey 13
i created this i have a requirement if my case owner is user than all user show picklist otherwise sow queue. 
public class roleexten 
{
        public Case cse {get; set;}
        public String selectedId {get;set;}
        public List<selectoption> UserOptionList{get;set;}

        public roleexten(ApexPages.StandardController controller)
        {
            cse  =new Case ();
            selected();
        }
        public pagereference assignowner()
        {
            return page.vfpageownerassign ;
        }
        
        public void selected()
        {
            UserOptionList = new List<selectoption>();

            UserOptionList.add(new selectoption('','--None--'));

            for(User u :[select id ,name from user ])
            {
                system.debug('@@@@u' +u);
                UserOptionList.add(new SelectOption(u.Id , u.Name));
            }
            system.debug('@@@@UserOptionList' +UserOptionList );
      
      for(Group gp :[Select Name, Id From Group where Type = 'Queue']) { 
     UserOptionList.add(new SelectOption(gp.Id , gp.name));
}
  }
}