Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

My company have about 6000 people, all of them are in AD. We have a big SharePoint portal and some sub SharePoint portal for internal use only. All of them are MOSS 2010. Each sub-portal have their own user groups. My question is, How can I config People Picker dialog to display sub portal groups and will display all user in that group when user choose. I do that be cause every times user want to add a people, they have to find/search through a list of 6000 people. We need to display a local group so they can choose quicker.

For example: We have Group A (100people) Group B(100people)... We want to select 50 people from group A then search in people picker will be problematic

Please help

share|improve this question
    
How is declared the PeoplePicker? –  Steve B Jul 2 '12 at 11:23
    
What do you means? –  Trinh Hoang Nhu Jul 2 '12 at 11:50
    
The PeoplePicker is a control, that can be declared in a custom page or webpart, automatically generated by SharePoint if you have a list with a user field, generated by you from a feature in Visual studio, etc. –  Steve B Jul 2 '12 at 11:55
    
Ah, we use people picker in a SharePoint form, (design by infopath) –  Trinh Hoang Nhu Jul 2 '12 at 11:58
add comment

2 Answers 2

I don't know about in Infopath, but the PeopleEditor control itself has a property 'SharePointGroup', which would only let you select users from within that group.

share|improve this answer
    
Yes, you're right, but then we can only select from that group. Not the others when we want. All I want is that it can search by group or filter by groups somehow –  Trinh Hoang Nhu Jul 2 '12 at 14:55
add comment
up vote 0 down vote accepted

I discover a way to do that using javascript. Modify C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\Picker.aspx ,add some combobox to select group.

List all group with following code:

var siteUrl = '/';
var groupsCallback = function(a){
    console.debug(a);
}
function retrieveAllUserGroups(callback) {
    var clientContext = new SP.ClientContext(siteUrl);
    groupsCallback = callback || groupsCallback;
    this.collGroup = clientContext.get_web().get_siteGroups();
    clientContext.load(collGroup);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onGroupsQuerySucceeded), Function.createDelegate(this, this.onGroupsQueryFailed));
}

function onGroupsQuerySucceeded() {
    var groupEnumerator = collGroup.getEnumerator();
    var SPG = [];
    while (groupEnumerator.moveNext()) {
        var oGroup = groupEnumerator.get_current();
        var gjson = {
            'id':           oGroup.get_id(),
            'title':        oGroup.get_title(),
            'description':  oGroup.get_description()
        }
        SPG.push(gjson);
    }
    if (groupsCallback){
        groupsCallback(SPG);
    }
}

function onGroupsQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

To list user from a group use this code:

function retrieveAllUsersInGroup(gid, callback) {
    var clientContext = new SP.ClientContext(siteUrl);
    usersCallback = callback || usersCallback;
    var collGroup = clientContext.get_web().get_siteGroups();
    var oGroup = collGroup.getById(gid);
    this.collUser = oGroup.get_users();
    clientContext.load(collUser);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onUsersQuerySucceeded), Function.createDelegate(this, this.onUsersQueryFailed));
}

gid is the group id taken from above code. Good luck

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.