Skip to content

Commit 2fca874

Browse files
patrikhellgrenAJIXuMuK
authored andcommitted
Added groupId property to People Picker
1 parent 1510162 commit 2fca874

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

docs/documentation/docs/controls/PeoplePicker.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ The People picker control can be configured with the following properties:
5757
| ---- | ---- | ---- | ---- | ---- |
5858
| context | WebPartContext | yes | Context of the current web part. | |
5959
| titleText | string | no | Text to be displayed on the control | |
60-
| groupName | string | no | group from which users are fetched. Leave it blank if need to filter all users | _none_ |
60+
| groupName | string | no | Group from which users are fetched. Leave it blank if need to filter all users. When both groupName and groupId specified groupName takes precedence. | _none_ |
61+
| groupId | number | no | Group from which users are fetched. Leave it blank if need to filter all users. When both groupId and groupName specified groupName takes precedence. | _none_ |
6162
| personSelectionLimit | number | no | Defines the limit of people that can be selected in the control | 1 |
6263
| required | boolean | no | Set if the control is required or not | false |
6364
| disabled | boolean | no | Set if the control is disabled or not | false |

src/controls/peoplepicker/IPeoplePicker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export interface IPeoplePickerProps {
3030
*/
3131
groupName?: string;
3232
/**
33+
* Id of SharePoint Group
34+
*/
35+
groupId?: number;
36+
/**
3337
* Maximum number of suggestions to show in the full suggestion list. (default: 5)
3438
*/
3539
suggestionsLimit?: number;

src/controls/peoplepicker/PeoplePickerComponent.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
7575
* Get initial persons
7676
*/
7777
private async getInitialPersons(props: IPeoplePickerProps) {
78-
const { groupName, webAbsoluteUrl, defaultSelectedUsers, ensureUser, principalTypes } = props;
78+
const { groupName, groupId, webAbsoluteUrl, defaultSelectedUsers, ensureUser, principalTypes } = props;
7979
// Check if a group property was provided, and get the group ID
8080
if (groupName) {
8181
this.groupId = await this.peopleSearchService.getGroupId(groupName, webAbsoluteUrl);
@@ -85,6 +85,8 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
8585
});
8686
return;
8787
}
88+
} else if (groupId) {
89+
this.groupId = groupId;
8890
} else {
8991
this.groupId = null;
9092
}

0 commit comments

Comments
 (0)