Skip to main content

Notifications

Power Automate - Using Connectors
Unanswered

Get Name from Username and Save it to a global variable

(0) ShareShare
ReportReport
Posted on by 39

I am creating a login page. the user puts in the username and password and clicks on the button "login". when he clicks on login, i want the PowerApps to go to the SharePoint, get the name from the list where username = username entered and save the result in a global variable

  • ESAIT Profile Picture
    ESAIT 39 on at
    Re: Get Name from Username and Save it to a global variable

    @v-dezhili-msft thank you dear there is no longer an error, but when i click on login for the next page, 

     I need on a screen load to have that name that was saved on the global variable to be shown automatically on top filling a label. when i click on the label, and choose text = global variable, it keeps returning as blank

  • Re: Get Name from Username and Save it to a global variable

    Hi @ESAIT ,

    Did you refresh the data source in Power Apps after you changed a field in a SharePoint list? You can also go to List Settings to see if the list names have been changed correctly.

    Best Regards,

    Dezhi

  • ESAIT Profile Picture
    ESAIT 39 on at
    Re: Get Name from Username and Save it to a global variable

    @v-dezhili-msft thank  you for your assistance

    i Named my columns same as your code with family name as LastName and First Name as FirstName

    but Power App is not accepting them as per the attached

  • Re: Get Name from Username and Save it to a global variable

    Hi @ESAIT ,

    Do you want to get the FullName of this user from the SharePoint table by Username when logging in?
    In my test my UserName, FirstName and lastName are all of type single line text in SharePoint table.

    If(TextInput3.Text=First(Filter(list3,UserName=TextInput3.Text)).UserName,Set(varName,First(Filter(list3,UserName=TextInput3.Text)).LastName&First(Filter(list3,UserName=TextInput3.Text)).FitstName))
    vdezhilimsft_0-1667200041041.png
    vdezhilimsft_1-1667200041042.png
    vdezhilimsft_2-1667200041043.png

    Best Regards,

    Dezhi

  • ESAIT Profile Picture
    ESAIT 39 on at
    Re: Get Name from Username and Save it to a global variable

    @v-dezhili-msft I checked the code now and it is similar to the one i used to check if the username and password exist in the sharepoint, yet i need to fetch the Name based on the username and save the name in the global variable

  • ESAIT Profile Picture
    ESAIT 39 on at
    Re: Get Name from Username and Save it to a global variable

    @v-dezhili-msft thank you for your assistance 

    1. i want to save the name to display it in the next screen and to use it in future queries

    2. Yes there is a username, password, first name, and last name

    3. yes 

     

    i will test what you sent me and update you. thank you 😀

  • Re: Get Name from Username and Save it to a global variable

    Hi @ESAIT ,

    1. You just want to save the username to a global variable or a record of the username when the user logs in?
    2. Is the user in your SharePoint table a person column?
    3. Do you have a Password column in your SharePoint table?
    In fact, there is a built-in global variable User() in Power Apps, which stores the information of the current Power Apps user. I did a test, in my scenario the user in my SharePoint table is a person column and I have a Password column. When I click on the login button I use filter() to find the username in sharePoint that is the same as the text input box, and compare the Password, if they are equal I use set() to save the username.

    If(TextInput4.Text=First(Filter(list3,person.DisplayName=TextInput3.Text)).Password,Set(glo,TextInput4.Text);Navigate(Screen6),Notify("error"))

    Best Regards,

    Dezhi

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard

Featured topics