cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MartinWS
New Member

Exclude disabled users and admins, and avoid duplicates

Hello Everybody,

 

I am fairly new at using powerapps, but i think you might be able to help me here.

 

Our system runs through Active Directory, and all users should as well be entered into out Office 365 system, which is the data source for the app in powerapps.

The app i am making is a simple Co-Worker lookup app, which is setup from the already existing template.

 

I now want to avoid the duplicates showing up. I dont know which way is the best, if office 365 users have a unique ID or simply just doing it by title. And i dont know how i should set it up.

 

Also i would like to exclude accounts that are of a different Sync type in Office 365.
Some of them are Sync type: Syncronised which i want to keep. Those are the users from out Active Directory. Some of them however are Sync Type: Cloud, which are users i dont want to show either.

 

Also, we have some active Admin accounts and users that are disabled, and i want to be able to avoid those. They all have "- ADM" in the end of the name (the admin accounts). Can i somehow use that to make users with "- ADM" or just "ADM" not show up?

 

Thank you alot in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @MartinWS ,

Do you want to avoid the duplicated Office 365 User records showing up within your Gallery?

Do you want to exclude accounts that are of a different Sync type in Office 365?

Further, do you want to exclude the active Admin accounts and users that are disabled within your Gallery?

 

Firstly, I think you have some misunderstanding on Office 365 Users. Each Office 365 User has a unique Id (or User Principal Name), so the result the Office365Users.SearchUser() formula returned would not contain duplicated records.

 

If you want to exclude accounts that are of a different Sync type in Office 365 based on the result the Office365Users.SearchUser() formula returned, I afraid that there is no way to achieve your needs. The result the Office365Users.SearchUser() formula returned does not contain the Sync type property.

More details about the available properties the Office365Users.SearchUser() formula returned, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/connections/connection-office365-users

 

If you want to exclude the active Admin accounts and users that are disabled within your Gallery, I have made a test on my side, please take a try with the following workaround:2.JPG

Set the Items property of the Gallery to following formula:

 

Filter(
Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}),
AccountEnabled = true,
EndsWith(DisplayName, "test")
)

Or

 

 

Filter(
       Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}), 
       AccountEnabled = true, 
       "test" in DisplayName
)

On your side, you should type the following formula:

 

 

If(
   !IsEmpty(SearchUser),
    Sort(
           Filter(
                    Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}),
                    Len(GivenName)>0,
                    AccountEnabled = true, 
                    EndsWith(DisplayName, "- ADM") /* <-- The "- ADM" text may be existed within the GivenName property of a user, so please type EndsWith(GivenName, "- ADM") */
           ),
           GivenName,
           Ascending
    )
)

Or

 

If(
   !IsEmpty(SearchUser),
    Sort(
           Filter(
                    Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}),
                    Len(GivenName)>0,
                    AccountEnabled = true, 
                    "- ADM" in DisplayName 
           ),
           GivenName,
           Ascending
    )
)

If the "- ADM" text existed within the GivenName property of one user's propfile, please modify above formula as below:

If(
   !IsEmpty(SearchUser),
    Sort(
           Filter(
                    Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}),
                    Len(GivenName)>0,
                    AccountEnabled = true, 
                    EndsWith(GivenName, "- ADM")
           ),
           GivenName,
           Ascending
    )
)

Or

If(
   !IsEmpty(SearchUser),
    Sort(
           Filter(
                    Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}),
                    Len(GivenName)>0,
                    AccountEnabled = true, 
                    "- ADM" in GivenName 
           ),
           GivenName,
           Ascending
    )
)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-xida-msft
Community Support
Community Support

Hi @MartinWS ,

Do you want to avoid the duplicated Office 365 User records showing up within your Gallery?

Do you want to exclude accounts that are of a different Sync type in Office 365?

Further, do you want to exclude the active Admin accounts and users that are disabled within your Gallery?

 

Firstly, I think you have some misunderstanding on Office 365 Users. Each Office 365 User has a unique Id (or User Principal Name), so the result the Office365Users.SearchUser() formula returned would not contain duplicated records.

 

If you want to exclude accounts that are of a different Sync type in Office 365 based on the result the Office365Users.SearchUser() formula returned, I afraid that there is no way to achieve your needs. The result the Office365Users.SearchUser() formula returned does not contain the Sync type property.

More details about the available properties the Office365Users.SearchUser() formula returned, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/connections/connection-office365-users

 

If you want to exclude the active Admin accounts and users that are disabled within your Gallery, I have made a test on my side, please take a try with the following workaround:2.JPG

Set the Items property of the Gallery to following formula:

 

Filter(
Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}),
AccountEnabled = true,
EndsWith(DisplayName, "test")
)

Or

 

 

Filter(
       Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}), 
       AccountEnabled = true, 
       "test" in DisplayName
)

On your side, you should type the following formula:

 

 

If(
   !IsEmpty(SearchUser),
    Sort(
           Filter(
                    Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}),
                    Len(GivenName)>0,
                    AccountEnabled = true, 
                    EndsWith(DisplayName, "- ADM") /* <-- The "- ADM" text may be existed within the GivenName property of a user, so please type EndsWith(GivenName, "- ADM") */
           ),
           GivenName,
           Ascending
    )
)

Or

 

If(
   !IsEmpty(SearchUser),
    Sort(
           Filter(
                    Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}),
                    Len(GivenName)>0,
                    AccountEnabled = true, 
                    "- ADM" in DisplayName 
           ),
           GivenName,
           Ascending
    )
)

If the "- ADM" text existed within the GivenName property of one user's propfile, please modify above formula as below:

If(
   !IsEmpty(SearchUser),
    Sort(
           Filter(
                    Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}),
                    Len(GivenName)>0,
                    AccountEnabled = true, 
                    EndsWith(GivenName, "- ADM")
           ),
           GivenName,
           Ascending
    )
)

Or

If(
   !IsEmpty(SearchUser),
    Sort(
           Filter(
                    Office365Users.SearchUser({searchTerm:TextSearchBox1.Text}),
                    Len(GivenName)>0,
                    AccountEnabled = true, 
                    "- ADM" in GivenName 
           ),
           GivenName,
           Ascending
    )
)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Users online (3,507)