cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pbrainard
Helper III
Helper III

Disable Button based on values in collection

I have a form that defaults to New when it loads. It's a form that collects two scores. The scores are written to a table with the ID of an item from another form/SP list.

 

I've created a collection of the scoring table ONSTART. How can I check the ID column in the collection, and compare the logged in user (maybe against Created By column) to determine if the logged in user already scored this item, and disable the Submit Score button? I only want to Submit Score button active if a user has not scored the item.

1 ACCEPTED SOLUTION

Accepted Solutions
TheRobRush
Super User
Super User

Made a test on my side, and it works this way for our organization. User().Email and ThisItem.Author.Email do not match because our company has multiple email aliases and powerapps looks at different ones depending on what record source is User() vs Author column in sharepoint etc. So here is how I got around THAT and made it look at same version of email for either

 

If(
    Office365Users.UserProfileV2(User().Email).mailNickname
    =
    Office365Users.UserProfileV2(ThisItem.Author.Email).mailNickname,
    DisplayMode.Edit,
    DisplayMode.Disabled)

 

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

View solution in original post

4 REPLIES 4
TheRobRush
Super User
Super User

Made a test on my side, and it works this way for our organization. User().Email and ThisItem.Author.Email do not match because our company has multiple email aliases and powerapps looks at different ones depending on what record source is User() vs Author column in sharepoint etc. So here is how I got around THAT and made it look at same version of email for either

 

If(
    Office365Users.UserProfileV2(User().Email).mailNickname
    =
    Office365Users.UserProfileV2(ThisItem.Author.Email).mailNickname,
    DisplayMode.Edit,
    DisplayMode.Disabled)

 

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!
TheRobRush
Super User
Super User

that code was placed in the DisplayMode of my button and provided the desired results

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

And I can add the item ID to see if the particular item has already been scored?

TheRobRush
Super User
Super User

Sure, if you need to do two checks, one for person and one for score just wrap them in an and And() or throw && between them

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,760)