cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Disable Button if user using the app != DataCardValue

I've built an app that holds the records of a select list of people (pulled from a SharePoint list) with their details.

 

I want to create the app so that those people can self-manage their records by editing their own, but hide/disable the button that takes them to the gallery for editing said user record IF the user using the app does not have the same email address as the record they are viewing, which is showing on a DataCardValue.

 

I've set a variable for OnStart to Set(varUserEmail, User().Email) so we have that variable to play with.

 

I've tried to get this to work with a simple query on the Visible property:

 

varUserEmail = ThisItem.DataCardValue12  - This results in incompatible data type error (that's the datacard that returns the email address I want to match against the variable)

 

I think I'm approaching this the wrong way as every variation I try complains about the data type error.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@Anonymous 

ThisItem.DataCardValue12.Text

View solution in original post

5 REPLIES 5
Drrickryp
Super User
Super User

@Anonymous 

ThisItem.DataCardValue12.Text

Anonymous
Not applicable

I'm still getting the same error when using varUserEmail = ThisItem.DataCardValue12.Text

 

I suspect I know why however, but correct me if I'm wrong. The text value in the DataCard is not hardcoded in. It's Parent.Default. I assume it's not 'seeing' the text being returned from the datacard.

 

I'm looking at using varUserEmail = User().Email as it is returning mine (though I need to test it further) 

@Anonymous 

There is nothing wrong with using your variable, in fact, it is highly suggested.  However, your first formula references the control itself, not the data in it.  Since you didn't mention the type of control (textinputbox, combobox, dropdown, etc), I assumed it was a text input box. If the list contains the user's email, in a column such as youremail,  you can just reference it directly.  Set the visibility of the button to varUserEmail = ThisItem.youremail

Anonymous
Not applicable

Thank you for the patience on this one @Drrickryp 

 

I'll explain further and provide screenshots for additional context.

 

I have a label and an icon I want to hide if the user currently using the app isn't what the text on the DataCardValue12 is showing. We get that users email from the email variable and the DataCardValue12 value is a field pulled from the SharePoint list.

 

I understand what you mean by value type and I see that my original one wasn't referencing what type was in there. 

 

Anonymous
Not applicable

So I figured it out and discovered I was editing the wrong field. I assumed the 'visible' field was the relevant field but it was the DisplayMode field I needed to change. It was a simple If statement after that:

 

If(
DataCardValue12.Text = varUserEmail,
DisplayMode.Edit,
DisplayMode.Disabled
)

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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