Thursday, September 8, 2022

PowerApps: Search User In Azure AD

Hello Friends,
Welcome back with another post on PowerApps. In previous post, we learned about fetching of groups and then it's members.


Today, we will learn about fetching the Users from Azure AD. So, let's start-
  1. Add a blank screen named "ScreenADUsers".
  2. Now Add below controls-
    1. Label - lblSearchUserLabel
    2. Text Input - txtSearchUserText
    3. Button - btnLoadUsers
    4. DataTable - dtUsers
  3. Initially, add Label, Text input, button.
  4. Now, click on "Data" link from left navigation menu and the click on "Add data".
  5. Here we will add "Office 365 Groups" connection. Search for "office 365".
  6. Select the "Office 365 Users" connector.
  7. Now, on "OnSelect" property of btnLoadGroups, we will add below code to fetch Users.
    1. ClearCollect(
          collOffice365Users,
          RenameColumns(
              Office365Users.SearchUser({searchTerm: txtSearchUserText.Text}),
              "DisplayName",
              "Member Name",
              "Mail",
              "Email ID",
              "Id",
              "ID",
              "UserPrincipalName",
              "User Principal Name"
          )
      );
      
  8. Run the app and click on button so that the collection get its structure.
  9. Now, add one DataTable (as mentioned above) named "dtUsers'. Provide the collOffice365Groups as Data Source. Then click on "Edit Fields" link and choose "Member Name", "ID", "Email ID", "User Principal Name".
  10. That's all. Publish the app and see the magic.
  11. If the text will be blank, it will fetch all users, otherwise, based upon the input, it will search the data.
  12. This is how, you can fetch the users.
With this, I am concluding this post.
Happy Coding !!!
Will see you again with some new topics.

Stay Safe !
Stay Healthy !

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.