cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Prodigy
Post Prodigy

Get emails from excel database and make a dropdown editable if they match emails with the user

Basically I want to have a table and a column with some emails and I want only a few able to edit a dropdown box.

Currently this is my code that works with the email only: 

If(User().Email = "firstemailfromuser@hotmail.com" || User().Email = "secondemail@hotmail.com", DisplayMode.Edit, DisplayMode.View)

 

How do I get the email address from the table?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Get emails from excel database and make a dropdown editable if they match emails with the user

@TimoMigchielsen 

Make a new label in your app and put this code in the Text property

User().Email

 

Now look at your AllowedUsers list in Excel.  Is it exactly the same?  All letters in your email. must be the same case (upper or lower) as the email in your Excel.

 

Another idea is you might need to refresh your Excel list list in PowerApps Studio after making changes.  Go to the left-side menu, click on the 3 dots beside the OneDrive connector, then refresh.

 

If none of these works try to see if you can simply get this code in OnStart working.  Make sure to Run OnStart after making changes.

Set(isUserAllowed, User().Email in ["youremail@company.com"])

 

Let me know the result of all these tests.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

 

 

 

View solution in original post

Highlighted
Resolver III
Resolver III

Re: Get emails from excel database and make a dropdown editable if they match emails with the user

@TimoMigchielsen ,

 

 

Try and use this code instead:

Set(gblUser, User().Email);
ClearCollect(colAdminList,Admins);
Set(
    gblIsAdmin,
    !IsBlankOrError(
        LookUp(
            colAdminList,
            Administrators = gblUser
        )
    )
)

 

The "Collect(colAdminList,Admin.Administrators);"  will fetch all the record in your table and put them in a local table in the app that will store your records , this is a temporary storage that will be cleaned when you close the app , (collection) with only the column administrators.

 

But there is a problem here when collecting he expect a datasource (your excel table) with items. In your formula you use Admin instead of Admins.

Also in your table you only have 1 column named "Administrators", so there is no need to collect only this column and you can just collect the full table.

 

The difference between the Collect() and ClearCollect() function is the following:

If you have a Collection with lets say 5 items and you do the collect function, all the records that you collect will be added in this colletion.

If you use the ClearCollect() function you will first empty this collection and than add the records. In this case it also wouldn't matter because this is on start but for good measure I make a habit of using ClearCollect 

View solution in original post

27 REPLIES 27
Highlighted
Resolver III
Resolver III

Re: Get emails from excel database and make a dropdown editable if they match emails with the user

Hello @TimoMigchielsen ,

 

Is this in a gallery?

Highlighted
Super User III
Super User III

Re: Get emails from excel database and make a dropdown editable if they match emails with the user

@TimoMigchielsen 

 

For example, lets say you have an Excel table called "AllowedUsers" with a single column like this:

 

Email
firstemailfromuser@hotmail.com
secondemailfromuser@hotmail.com

 

Put this code in the OnStart property of your app.

Set(isUserAllowed, User().Email in AllowedUsers.Email)

 

Finally, use this code in the DisplayMode property of your dropdown.

If(isUserAllowed=true, DisplayMode.Edit, DisplayMode.View)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Super User II
Super User II

Re: Get emails from excel database and make a dropdown editable if they match emails with the user

Assuming you have your Excel source, let's assume it's called ExcelFile, and has a Table called Emails.

I would begin by setting a variable with the User's Email (global, or local)

  • Set(gblUserEmail,User().Email)
  • UpdateContext({locUserEmail: User().Email})

Then you can check for that variable in the Table's columns.

If(
    gblUserEmail in ExcelFile.emailColumnName,
    DisplayMode.Edit, // If found
    DisplayMode.View // If not found
)

Given that it's an IF function, this can be used for any behavior (like the DisplayMode in your example, but could also be for show/hide, or any other outcome based on the IF evaluation).

Highlighted
Post Prodigy
Post Prodigy

Re: Get emails from excel database and make a dropdown editable if they match emails with the user

Hey!

I've tried this and I do not get an error. My email is exact the same as in the table but I am only able to view it... What do I do? @mdevaney 

Highlighted
Super User III
Super User III

Re: Get emails from excel database and make a dropdown editable if they match emails with the user

@TimoMigchielsen 

Make a new label in your app and put this code in the Text property

User().Email

 

Now look at your AllowedUsers list in Excel.  Is it exactly the same?  All letters in your email. must be the same case (upper or lower) as the email in your Excel.

 

Another idea is you might need to refresh your Excel list list in PowerApps Studio after making changes.  Go to the left-side menu, click on the 3 dots beside the OneDrive connector, then refresh.

 

If none of these works try to see if you can simply get this code in OnStart working.  Make sure to Run OnStart after making changes.

Set(isUserAllowed, User().Email in ["youremail@company.com"])

 

Let me know the result of all these tests.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

 

 

 

View solution in original post

Highlighted
Post Prodigy
Post Prodigy

Re: Get emails from excel database and make a dropdown editable if they match emails with the user

Only thing I had to do was refreshing.... Thanks!

Highlighted
Post Prodigy
Post Prodigy

Re: Get emails from excel database and make a dropdown editable if they match emails with the user

I've now tried to remove a letter from the email in my excel file from administrators and refreshed the data source and I am still able to edit it so this does not work. What can I do to fix it? @mdevaney 

Highlighted
Post Prodigy
Post Prodigy

Re: Get emails from excel database and make a dropdown editable if they match emails with the user

Removed all emails from the list and everyone is able to edit it. Kind of strange

Highlighted
Post Prodigy
Post Prodigy

Re: Get emails from excel database and make a dropdown editable if they match emails with the user

Does anyone know how to fix this? 

@mdevaney 
@GarethPrisk 
@KennethNicasens 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (5,206)