function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
S SaiS Sai 

public group wise users display in visualforce page

HI

i want to create visualforce page based on public group.

for example i have two groups A, B in visaulforce search box i give the value of A Group users display in to the table format in visualforce page 

Thanks 
SS
 
Best Answer chosen by S Sai
Tejpal KumawatTejpal Kumawat
Hello Friend,

Use this one & change per your requirement :
<apex:page controller="OppMatrix">
    <apex:form>
        <apex:inputText value="{!groupName}"/>
        <apex:commandButton value="Search" action="{!search}" reRender="opId"/>
        
        <apex:outputPanel id="opId">
        {!users}
        </apex:outputPanel>
    </apex:form>
</apex:page>
public class OppMatrix{
    public string groupName{get; set;}
    public list<User> users {get; set;}
    public OppMatrix(){
        groupName = '';
        users = new list<User>();
    }
    
    public void search(){
        set<string> setUser = new set<string>();
        for(GroupMember  gm : [Select g.Id, g.UserOrGroupId, g.GroupId From GroupMember g where Group.Name =: groupName]){
            setUser.add(gm.UserOrGroupId);
        }
        
        users = [select Id, name from User Where Id IN : setUser];
    }
}
Regards
Tej Pal Kumawat
Skype : tejpalkumawat1991

If this answers your question mark Best Answer it as solution and then hit Like!

 

All Answers

Tejpal KumawatTejpal Kumawat
Hello Friend,
You need query on GroupMember for your controller and show in the table.
list < GroupMember > publicGroupMembers = new List < GroupMember > ([Select g.Id, g.UserOrGroupId, g.GroupId From GroupMember g where Group.Name = 'A']);
Regards
Tej Pal Kumawat
Skype : tejpalkumawat1991

If this answers your question mark Best Answer it as solution and then hit Like!
S SaiS Sai
Hi Tejpal,
I want to dispaly Group wise 
Thanks 
SS
S SaiS Sai
User-added image
inputtext i am give publicgroup name after click the search button then is's dispaly the group users

THANK 
SS
 
Tejpal KumawatTejpal Kumawat
Hello Friend,

Use this one & change per your requirement :
<apex:page controller="OppMatrix">
    <apex:form>
        <apex:inputText value="{!groupName}"/>
        <apex:commandButton value="Search" action="{!search}" reRender="opId"/>
        
        <apex:outputPanel id="opId">
        {!users}
        </apex:outputPanel>
    </apex:form>
</apex:page>
public class OppMatrix{
    public string groupName{get; set;}
    public list<User> users {get; set;}
    public OppMatrix(){
        groupName = '';
        users = new list<User>();
    }
    
    public void search(){
        set<string> setUser = new set<string>();
        for(GroupMember  gm : [Select g.Id, g.UserOrGroupId, g.GroupId From GroupMember g where Group.Name =: groupName]){
            setUser.add(gm.UserOrGroupId);
        }
        
        users = [select Id, name from User Where Id IN : setUser];
    }
}
Regards
Tej Pal Kumawat
Skype : tejpalkumawat1991

If this answers your question mark Best Answer it as solution and then hit Like!

 
This was selected as the best answer
S SaiS Sai
HI Tejpal Kumawat,

thanx for reply. But i want to display user name,role also
thanks 
SS