Search for persons and groups

Applies to: Skype for Business 2015

A Person represents a user. The Person object can be queried for information about a person, such as their availability to join a conversation. The Person object is passed to the conversation starting methods, such as the ConversationsManager.getConversation method, so that the conversation invitation is sent to the person represented by the Person object.

A Group can represent a distribution group, server-defined person set, or user-defined person set. If the Group is a distribution group, it can also link to other distribution groups. Persons in a distribution group are represented by Person objects. The arguments for the PersonsAndGroupsManager.createPersonSearchQuery method include a partial or full name query and a numeric limit to the size of the result sets. Results include a collection of distribution groups. To find persons, use the PersonsAndGroupsManager.createPersonSearchQuery method. The following procedure assumes that a user has signed in before searching for persons and groups.

Search for persons

  1. Create a SearchQuery for person search: personsAndGroupsManager.createPersonSearchQuery.

  2. Specify the search terms and a limit to the number of possible results in the SearchQuery.

  3. Execute the searchQuery.getMore method and get the search results in the onSuccess method.

  4. Call the forEach method of the array of results. For each result, Person object is the result.result.

Note

The maximum number of results for a person search query is 50.

var personSearchQuery = application.personsAndGroupsManager.createPersonSearchQuery();
personSearchQuery.text('John Doe');
personSearchQuery.limit(50);
personSearchQuery.getMore().then(null, function (results) {
  results.forEach(function (result) {
    var person = result.result;
    console.log('Person ', person.displayName());
    // success - Contact Found            
  }, 
  function (error) {
   // handle error
  });
});

Search for groups

  1. Create a SearchQuery for group search: personsAndGroupsManager.createGroupSearchQuery.

  2. Specify the search terms a limit to the number of possible results in the SearchQuery.

  3. Execute the searchQuery.getMore method and get the search results in the onSuccess method.

  4. Call the forEach method of the array of results. For each result, Group object is the result.result.

var groupSearchQuery = application.personsAndGroupsManager.createGroupSearchQuery();
groupSearchQuery.text('mygroup');
groupSearchQuery.limit(50);
groupSearchQuery.getMore().then(null, function (results) {
    results.forEach(function (result) {
      var group = result.result;
      console.log('Distribution Group ', group.name());
      // success - Group Found
    }, 
    function (error) {
      // error
    });
});

See also

Get a person and listen for availability