I am currently working on a requirement where I need to assign users to a queue.

I have created one VF page which dynamically pulls the users list show in VF page. When an agent selects the users from vf page and clicks on Save button then all the selected users should go to the queues(lets say ABC queue).Kindly note the queue is already existing and created OOTB features not through apex


So basically the list above shows apple,banana(in my case it would be users) etc and showing in VF page.Now my challenge is when I select the members of list(it can be one/it can be multiple also) and clicks on Save button then the selected members from list should be assign to a queue lets say queue name= ABC which is already available in my org Below is my VF page developed so far:

<apex:page controller="TeleSalesList" sidebar="false" lightningStylesheets="true">

    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");                  
            for(var i=0; i<inputCheckBox.length; i++){          
                    inputCheckBox[i].checked = obj.checked;

<apex:form >
    <apex:pageBlock title="Welcome Back {!$User.FirstName}" mode="edit">
        <apex:pageBlockSection title="Today's Date" collapsible="false">
        <apex:outputText value="{0,date}" title="Today's Date:">
        <apex:param value="{!Today}"/>

        <apex:pageBlockSection title="Available Agents" columns="9" collapsible="false">
            <apex:variable var="rowNum" value="{!0}"/>
              <apex:pageBlockTable value="{!wrapAgentList}" var="accWrap" id="table" title="Available Agents">
                 <apex:column headerValue="S.No">
                     <apex:variable var="rowNum" value="{!rowNum + 1}"/>

                <apex:column headerValue="Name">
                <!--<apex:column value="{!accWrap.teleAgent.TeleSales_Agent__c}" />-->

                 <apex:column >
                    <apex:facet name="header">
                        <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                    <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>

         <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!doFullSave}"/>
                <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/>

Below is my apex class developed so far

public class TeleSalesList {
    public Date Today { 
    get { 
        return Date.today(); 
    public List<wrapAgent> wrapAgentList{get; set;}

    public TeleSalesList (){
    if(wrapAgentList == null) {
        wrapAgentList = new List<wrapAgent>();

        for(User teleSalesAgent: [select Id, Name from User where ID IN('0056F00000C7fSS','0056F00000C7fSm','0056F00000Cs2aS','0056F00000Bg480','0056F00000BMoxD',
                                    '0056F00000C7lGm','0056F00000Bg47H','0056F00000BgSEp')]) {
            // As each agent is processed we create a new wrap object and add it to the wrapAgentList
            wrapAgentList.add(new wrapAgent(teleSalesAgent));

    public void doFullSave(){
    //I need to put the logic here which I am not able to do so

    //return null;
    public PageReference doCancel(){
         //return null;
         PageReference pageRef = new PageReference('/');
            return pageRef;

    public class wrapAgent{
    public User teleAgent {get; set;}//Please put the custom metadata names
    public Boolean selected {get; set;}

    //This is the contructor method. When we create a new object we pass a 
    telesales metadata member that is set to the acc property. We also set the 
    selected value to false
    public wrapAgent(User teleSalesAgent) {
        teleAgent = teleSalesAgent;
        selected = false;


  • 4
    What is the actual issue you are having? Are you getting error messages? Why are you storing users in custom metadata? Your code also seems to be focused on accounts which doesn't seem to be related to what you're actually asking for.
    – gNerb
    Aug 13, 2019 at 16:39
  • @gNerb- Issue which I am facing is not able to redirect/assign the user to queue(name=ABC) when selects the checkbox against the agent name Aug 14, 2019 at 4:13
  • @gNerb-I have modified the class to change the logic to fetch users list from USER instead of metadata.Still I hv no idea how to move ahead.When manager selects users from VF page using checkbox and clicks on Save then users should assign to queue(queue is already present) Aug 14, 2019 at 14:03
  • Never ever hard-code Ids.
    – Adrian Larson
    Aug 14, 2019 at 14:05
  • @AdrianLarson-Thanks for your feedback and yes I am aware about the hardcoding should not be done.At present my main objective to get the working solution for my requirement atleast.I can change the hardcoded values to other value later on Aug 14, 2019 at 14:26


Browse other questions tagged .