cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Enforce unique values in Power Apps in User Email column

Hello,

 

I've seen some similar topic posts on what I'm about to ask, and have tried using them for my own purposes, but unfortunately to no avail. Most likely due to my own inexperience with Power Apps.

 

Anyway, I'm needing a way to enforce unique values for a User Email column on the Power Apps side, but not the SharePoint list itself. I need to be able to make it so users can't put their email in for more than one item in the Power App but can from the SharePoint list side. Is this possible and if not, any suggestions for how I might go about getting a similar result?

 

TIA!

 

 

Also, for reference on why I need it set up this way: I essentially need 2 different forms of input for the SharePoint list because all but one group of the users that will be inputting to this list need to be restricted to only having their email allotted for one item at a time. So, this one group will be the only ones that will be allowed to have multiple entries under their one email. My thinking for this would be that all the other users would be given the Power App for inputting purposes while the ones allowed multiple entries would have sole access to the list itself.

And for clarification, I do not need each user to be restricted to one entry total, because some users may be inputting items for other users and listing said other users' email for that item. In other words, one user could have several entries they created but each one still has a unique email. I started another topic question with a different approach to this issue which I will link below if anyone is interested. I started this new post just to expand my options. Thanks again.

Re: Enforce Unique Values for Every User Except On... - Power Platform Community (microsoft.com)

7 REPLIES 7
poweractivate
Most Valuable Professional
Most Valuable Professional

@Becca_Hayes 

Yes it's possible @Becca_Hayes 

 

Let me tell you the difference between using the SharePoint List way and not using it, to enforce uniqueness.

 

To enforce unique values in a SharePoint list:

 

1. Go to your SharePoint List and then, click on the name of the column that you want to enforce unique values on (in this case, it's the User Email column).

2. Click on "Column settings" and then "Edit".

3. In the column settings, you should find a checkbox saying "Enforce unique values".

Check it and save your changes.

 

This should enforce unique values for that column in the SharePoint list, meaning no two items in the list can have the same value in this column.

 

However, you've mentioned that you do not want to enforce this uniqueness constraint on the SharePoint list itself as there's one group of users who should be able to enter multiple items with the same email. This is why enforcing the constraint on the Power Apps side, not on the SharePoint list itself, would be more suitable for your scenario.

 

Enforcing unique values in Power Apps:

 

1. In your Power App, select the 'Submit' button that users use to submit the form.

2. In the OnSelect property of the button, write a formula to check whether the email a user entered already exists in the SharePoint list. If it does, show an error message and prevent the form from being submitted:

 

If(
IsBlank(
LookUp(
YourSharePointList,
EmailColumnName = TextInput1.Text
)
),
SubmitForm(YourFormName), // submit the form if email is unique
Notify("This email has already been used. Please enter a different email.", NotificationType.Error)
)

 

This formula uses the IsBlank function to check if the result of the LookUp function returns a record (i.e., no item in the SharePoint list has the same email). If it is blank, the formula submits the form. If it's not, the formula shows a notification to the user.

 

Remember to replace 'YourSharePointList', 'EmailColumnName', 'TextInput1', and 'YourFormName' with your actual SharePoint list name, the email column name, the actual TextInput control where users input their email, and the actual form name, respectively.

 

With this approach, you're implementing the uniqueness constraint only in your Power App, not in your SharePoint list. Users who use the Power App to submit data will be constrained by this rule, but users who have access to the SharePoint list itself will not be constrained.

 

Hope it helps @Becca_Hayes 

@poweractivate 

Thank you for such a detailed reply! I definitely think this is a step in the right direction as the formula is actually more complete than my previous attempts. However, something still seems to be wrong. I tried plugging in the formula you gave and when I try to submit the form to test it, it doesn't seem to do anything. No loading or any indication that the item is processing, or even getting the error message that is supposed to appear when the email is a duplicate.

 

I applied all this to OnSelect property of the submit button of the form as you stated and made sure to replace all the filler text of the formula with my own information. I have attached below what the formula looks like for me currently if you wouldn't mind taking a look. The only information that isn't shown is my list name as it needs to remain private.

 

Becca_Hayes_0-1690986474447.png

As you can see in the photo, the .Text portion is underlined in red, but I have had this happen on another App and the formula for that one still worked, so not sure if this is part of the issue. I would like to note in case it makes a difference that the User Email column is a person lookup, not just a plain text column. If this is the issue, then I can just change it to a text column if that is the quickest solution.

 

@Becca_Hayes 

 

From what you've described, the issue could indeed be related to the 'User Email' column being a person lookup. When you're dealing with a person lookup column, you have to reference it slightly differently in the LookUp function because the data structure of a person lookup is different from that of a simple text field.

Here is a modification to the formula that accounts for the person lookup:

 

If(
   IsBlank(
      LookUp(
         redacted,
         'User_x0020_Email'.Email = DataCardValue11.Text
      )
   ),
   SubmitForm(EditForm), // submit the form if email is unique
   Notify("This email has already been used. Please enter a different email.",NotificationType.Error)
)

 


Here, 'User_x0020_Email'.Email is used instead of User_x0020_Email.

This is because a person lookup column is a record that contains several fields, one of which is 'Email'.

So, you actually need to specify that you're checking the 'Email' field of the 'User Email' column.

 

I hope this helps, @Becca_Hayes 

poweractivate
Most Valuable Professional
Most Valuable Professional

@Becca_Hayes 

 

You may alternatively change it to a text field if it is simpler for you as well, but you may also check my previous response to see if you can get it to work with your Person lookup column.

@poweractivate 

 

It still doesn't seem to want to work. I tried just creating a text column for the email and used the original formula you gave me, and it worked, so I may have to just go that route for now. It isn't ideal though because the organization I work for is big and it may be troublesome to have to manually type in everyone's emails.

 

If you have any other ideas to try to get the person lookup column to work, I'd be very grateful. If not, no problem, you have already been a huge help to me, and I at least have some direction to go in for now.

 

Thank you.

@Becca_Hayes 

Based on this, it sounds like the issue may still be with correctly referencing the 'User Email' person lookup column. There are a few things that might be going wrong:

 

1. Incorrect Column Reference: Ensure that the 'User_x0020_Email'.Email is the correct way to reference the email field in your person lookup column. The names used to reference columns and fields in Power Apps are sometimes different than the names displayed in the SharePoint list. You can check this in the app by using the formula: First(redacted).'User Email'. This should return a record with the data structure of the 'User Email' column.

2. Data Types: Ensure that the data you're comparing is of the same type. For example, if 'User_x0020_Email'.Email is a text field, ensure that DataCardValue11 is also a text field where DataCardValue11.Text really gives you text. Power Apps is case-sensitive and type-specific, so make sure your comparisons match in both case and data type.

3. Presence of Email: Make sure that every person in the 'User Email' column has an email associated with them. If some of the entries are blank or have invalid emails, this could potentially cause issues with the lookup.

 

I hope this helps you @Becca_Hayes 

As far as I know, the column referencing is all correct. And the people I'm using for testing are on my team, so I know they have proper emails associated with their lookup profiles.

 

So, I'm assuming based on what you've said that it would be the data types that is the issue, then. The User Email column is a Person or Group lookup in the SharePoint list and the input field (DataCardValue11) in the Power App is a combo box, by default. So, not sure if that's a proper match-up, but I would've assumed the combo box by design is meant for things like person or group fields so not sure that's really the issue. Not sure if this is what you mean by the data types, either, but I tried playing around with the settings of the combo box anyway to see if that would help and so far, nothing.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (488)