+ Start a Discussion
Cris9931Cris9931 

i want to change in Queue Name

Hi, I want to change my column from 'Name' into 'Queue Name'. Is it possible?

User-added image

my VF code

 

<apex:page controller="Search_For_User">
<apex:form style="width: 500px" >
       <apex:pageBlock tabStyle="Account" >

              <apex:inputText value="{!keyword}"/>
              <apex:commandButton value="Search" action="{!searchUser}"/>

            <Apex:pageblockTable value="{!results}" var="r" style="width: 450px">
                  <apex:column value="{!r.FirstName}" />
                  <apex:column value="{!r.LastName}" />
                  <apex:column value="{!r.ProfileId}"/>
            </Apex:pageblockTable>
              <Apex:pageblockTable value="{!groupMembers}" var="g" style="width: 200px">
                  <apex:column value="{!g.Group.Name}"/>
           </Apex:pageblockTable>
            
       </apex:pageBlock>
</apex:form>
</apex:page>
Best Answer chosen by Cris9931
Khan AnasKhan Anas (Salesforce Developers) 
Hi Cristian-Ovidiu,

Greetings to you!

You can use the headerValue attribute of apex:column tag. 
headerValue: The text that should be displayed in the column header. If you specify a value for this attribute, you cannot use the column's header facet. Note also that specifying a value for this attribute overrides the default header label that appears if you use an inputField or outputField in the column body.

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_column.htm

Try below code:
<apex:page controller="Search_For_User">
<apex:form style="width: 500px" >
       <apex:pageBlock tabStyle="Account" >

              <apex:inputText value="{!keyword}"/>
              <apex:commandButton value="Search" action="{!searchUser}"/>

            <Apex:pageblockTable value="{!results}" var="r" style="width: 450px">
                  <apex:column value="{!r.FirstName}" />
                  <apex:column value="{!r.LastName}" />
                  <apex:column value="{!r.ProfileId}"/>
            </Apex:pageblockTable>
              <Apex:pageblockTable value="{!groupMembers}" var="g" style="width: 200px">
                  <apex:column headerValue="Name" value="{!g.Group.Name}"/>
           </Apex:pageblockTable>
            
       </apex:pageBlock>
</apex:form>
</apex:page>

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Cristian-Ovidiu,

Greetings to you!

You can use the headerValue attribute of apex:column tag. 
headerValue: The text that should be displayed in the column header. If you specify a value for this attribute, you cannot use the column's header facet. Note also that specifying a value for this attribute overrides the default header label that appears if you use an inputField or outputField in the column body.

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_column.htm

Try below code:
<apex:page controller="Search_For_User">
<apex:form style="width: 500px" >
       <apex:pageBlock tabStyle="Account" >

              <apex:inputText value="{!keyword}"/>
              <apex:commandButton value="Search" action="{!searchUser}"/>

            <Apex:pageblockTable value="{!results}" var="r" style="width: 450px">
                  <apex:column value="{!r.FirstName}" />
                  <apex:column value="{!r.LastName}" />
                  <apex:column value="{!r.ProfileId}"/>
            </Apex:pageblockTable>
              <Apex:pageblockTable value="{!groupMembers}" var="g" style="width: 200px">
                  <apex:column headerValue="Name" value="{!g.Group.Name}"/>
           </Apex:pageblockTable>
            
       </apex:pageBlock>
</apex:form>
</apex:page>

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer
Cris9931Cris9931

Hi Khan,

 

Thanks, it works!

 

Can you help me with one more thing?

Can I combine those two pageblockTables to be just only one? I don't want to be a separate table for Queues. I'm not sure how to do that with 2 pageblockTable values !results and !groupmembers.

 

I want my table to look like this:

 

User-added image

gowtham murugesangowtham murugesan
Hi Cristian-Ovidiu Trif,

can you post your controller class code for this above visual force code?
Cris9931Cris9931

Sure,

 

public class Search_For_User
{
    String keyword;
    
    List<user>results = new List<user>();
    List<GroupMember> groupMembers = new List<GroupMember>();
    public String getkeyword(){
    return keyword;
    }
    public List<user> getresults(){
    return results;
    }
    
    public void setkeyword(String input){
    keyword = input;
    }
    
    public PageReference searchUser(){
    results = (List<User>)[FIND :keyword IN NAME FIELDS RETURNING USER(FirstName, LastName, ProfileId)][0];
    
    
    return null;
   }
    
    public List<GroupMember> getgroupMembers(){
    Id[] idList = new List<Id>(new Map<Id, User>(results).keySet());
    GroupMember[] groupMembers = [select GroupId, Group.Name, UserOrGroupId from GroupMember where  UserOrGroupId IN :idList ];
      System.Debug('############################## ' +groupMembers);
    return groupMembers;
    }
}