Skip to content

Commit a052ae2

Browse files
Added groupId property to People Picker
1 parent e645128 commit a052ae2

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
@@ -60,7 +60,8 @@ The People picker control can be configured with the following properties:
6060
| ---- | ---- | ---- | ---- | ---- |
6161
| context | BaseComponentContext | yes | Context of the current web part. | |
6262
| titleText | string | no | Text to be displayed on the control | |
63-
| groupName | string | no | group from which users are fetched. Leave it blank if need to filter all users | _none_ |
63+
| 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_ |
64+
| 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_ |
6465
| personSelectionLimit | number | no | Defines the limit of people that can be selected in the control | 1 |
6566
| required | boolean | no | Set if the control is required or not | false |
6667
| 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
@@ -29,6 +29,10 @@ export interface IPeoplePickerProps {
2929
*/
3030
groupName?: string;
3131
/**
32+
* Id of SharePoint Group
33+
*/
34+
groupId?: number;
35+
/**
3236
* Maximum number of suggestions to show in the full suggestion list. (default: 5)
3337
*/
3438
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)