cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
A_MacMac
Regular Visitor

Unable to retrieve User() data

Hi everyone, 

 

Hoping to get some help on a Lookup formula. It works for me as the creator of the App, but not for anyone else.

 

I have a horizontal gallery that displays a range of employee data (name, email, department etc.) What I want to happen, is that when a user opens the app their record is the first to display, then they can search or scroll to see the other employees. But if their details aren't already in the data source, I want the gallery to just default display. So on the default property of my gallery, I have:

 

If(
    IsBlank(
        LookUp(
            Employee_Data,
            Email = User().Email
        )
    ),
    First(Self.AllItems),
    LookUp(
        Employee_Data,
        Email = User().Email
    )
)

 

 Another peculiarity I've noticed, is that I cannot set a variable to reliably return user data. Using the OnStart property of the App I've tried "Set(varCurrentUser, User())" but setting the text in a label on my gallery screen to "varCurrentUser.Email" gives me a blank label, and CurrentUser.Email = blank in the formula bar. Same story if I try to use the Office365Users connector to achieve the same outcome.

 

I'm stumped! Any help is greatly appreciated.

 

Audrey

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @A_MacMac :

About the formula:

I suggest you replace 'self.Allitems' with the value in the items property of this gallery

vbofengmsft_0-1646975823500.png

About the OnStart property:

In edit mode, OnStart will not be executed automatically, you need to trigger this event manually

vbofengmsft_1-1646976050176.png

Best Regards,

Bof

 

View solution in original post

ArchitectMadhan
Super User
Super User

Hi @A_MacMac ,

 

In order to assign the Current User in a variable, please use the "OnStart" in App as shown below, and then you will be able to use the variable in forms.

ArchitectMadhan_0-1646979135828.png

Using the variable in form:

ArchitectMadhan_1-1646979187601.png

Please click the button Accept as Solution and give thumbs up, if it is helpful for you.

- Architect Madhan

Please click the "Accept as Solution" button and give thumbs up, if it is helpful to you.

View solution in original post

2 REPLIES 2
v-bofeng-msft
Community Support
Community Support

Hi @A_MacMac :

About the formula:

I suggest you replace 'self.Allitems' with the value in the items property of this gallery

vbofengmsft_0-1646975823500.png

About the OnStart property:

In edit mode, OnStart will not be executed automatically, you need to trigger this event manually

vbofengmsft_1-1646976050176.png

Best Regards,

Bof

 

ArchitectMadhan
Super User
Super User

Hi @A_MacMac ,

 

In order to assign the Current User in a variable, please use the "OnStart" in App as shown below, and then you will be able to use the variable in forms.

ArchitectMadhan_0-1646979135828.png

Using the variable in form:

ArchitectMadhan_1-1646979187601.png

Please click the button Accept as Solution and give thumbs up, if it is helpful for you.

- Architect Madhan

Please click the "Accept as Solution" button and give thumbs up, if it is helpful to you.

Helpful resources

Announcements
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.

Top Solution Authors
Top Kudoed Authors
Users online (3,845)