Connect to SharePoint
Creating an AD account in SharePoint with Power Apps requires you to have a Person or Group type field in a SharePoint list or library. For instance with QualityAccount :
Then the SharePoint list must be connected to your Power Apps application, via the Data menu (left pane). It’s an icon which looks like a database.
Then, all you have to do is indicate the SharePoint site and then the list selected in the right pane.
Obtain the claims of the current user
The User() function gives some information about the current user: her email, her full name and her image. That’s all.
Unfortunately, a crucial piece of information is missing: her Claims. You will find many websites which explain that Claims can be calculated using the Concatenate() function or the & operator, with the formula:
Set(glbCurrentUserClaims;"i:0#.f|membership|" & User().Email);
In this formula, the character string “i:0#.f|membership|” is fixed. It is independent of the user or the company.
In order to avoid consuming resources unnecessarily with calling the User() function, we prefer to use a global variable glbCurrentUser which is simply defined by:
The previous formula therefore becomes:
Set(glbCurrentUserClaims;"i:0#.f|membership|" & glbCurrentUser.Email);;
This formula is valid in simple cases. In particular, if your AD (Active Directory) is perfectly “clean” and consistent. However, this is not always the case.
This is because the claim can be constructed from a user’s email address that is different from the one provided by User().Email. You will therefore need to verify this with your IT administrator.
Create the user account in SharePoint
To add a user’s AD account in the QualityAccount field, of type Person, use the following complete formula:
Note that the Department, JobTitle and Picture fields are required for creating the account in the list. They can optionally be empty.
Another entry for the current user’s account in Power Apps.
Nullify a user account
To “blank” a user account in a SharePoint list, use the Blank() function 🙂
For example :
Retrieve the email address of a claim (Claims)
The Split () and Last () functions help us:
This formula will give:
Laisser un commentaire