Greetings everyone,
I have a form that includes a combobox of secretaries, and I need to display in that combobox only the secretaries who are active, and are internal accounts, and belong to the secretaries group. I mean to create a secretary picker.
The combobox cannot allow multiple selections, and I must display only names and emails. However, when saving the record in the SharePoint list, I need to store the user's ID. For instance, if I select Luisa Lane, whose email is llane@mycompany.com, I should save only 'llane' in the list.
I know I can achieve this using Office365Users and Office365Groups, but I'm not sure how to combine both functions.
Someone suggested that I could proceed this way:
// Step 1: Retrieve and filter users
ClearCollect(
FilteredUsers,
Filter(
Office365Users.SearchUserV2(
{
searchTerm: Trim(Self.SearchText),
isSearchTermRequired: false
}
).value,
AccountEnabled = true && Not("#EXT" in UserPrincipalName)
)
);
// Step 2: Retrieve group members
ClearCollect(
GroupMembers,
Office365Groups.ListGroupMembers("53d2e2dd-cdcd-4d58-86a7-56dd248d4e52").value;
Office365Groups.ListGroupMembers("da6aeda1-d6a9-474c-a2f9-b37347cb0937").value
);
// Step 3: Match and filter
ClearCollect(
FinalFilteredUsers,
Filter(
FilteredUsers,
// Check if the user is in the group members list
LookUp(GroupMembers, mail = UserPrincipalName) <> Blank()
)
);
However, I'm encountering numerous errors. I have the impression that everything revolves around collections, but I'm uncertain about what steps I should take.
This might be quite obvious or basic for some, but for me, it's a new concept, which is why I'm seeking help.
I wonder if someone could guide me on this.
Thank you very much in advance.