web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Retrieve username from...
Power Apps
Answered

Retrieve username from a canvas app and store it in a MS List; when a user turns the toggle switch On/Off on canvas app

(0) ShareShare
ReportReport
Posted on by 15

Hello,

I am new to power apps and am struggling with following problem.

I have a MS List named Demo1 with 5 columns namely:

Title(text)-name of machines,

EQ(number)-machine number,

Alarm(yes/no)-status of alarm,

DateTime(Datetime)- date and time

and Person(Person)- name of user

I have connected this list with a canvas app named Demo1 with UI just showing Title, EQ using labels and Alarm using toggle buttons, now I want that when a user selects the toggle button, the name of user and the date and time the toggle was clicked must get stored in the list. I used a patch function on Onselect property of toggle as

Patch(Demo1, First(Filter(Demo1, Title = Label1.Text)), {Alarm: Toggle1.Value}, {Person: User().FullName}, {DateTime: Now()}),

it throws an error that the expected type of argument of Person is record type but found type is text.
Any help would be much appreciated!

Categories:
I have the same question (0)
  • Verified answer
    BCBuizer Profile Picture
    22,844 Super User 2026 Season 2 on at

    Hi @pujaclb ,

     

    You can use the below to patch a person/group type column:

    Patch(
     Demo1, 
     LookUp(Demo1, Title = Label1.Text), 
     {
     Alarm: Toggle1.Value,
     Person: {Claims:"i:0#.f|membership|" & User().Email,Department:"",DisplayName:"",Email:"",JobTitle:"",Picture:""},
     DateTime: Now()
     }
    )

     

    Ps. I also removed some unnecessary parts of the formula like extra curly braces.

  • pujaclb Profile Picture
    15 on at

    Hi @BCBuizer thankyou for the help, it worked.

     

    I have one more query, I have created a label to display the username and datetime when a toggle is turned on/ off on the app. And I am using following formula on Text property of label:

    If(Toggle1.Value, Concatenate(Text(DateTimeValue(Now()), DateTimeFormat.ShortDateTime24), "/" , User().FullName), Concatenate(User().FullName, " /" , Text(DateTimeValue(Now()), DateTimeFormat.ShortDateTime24)))

    Is there a way to retrieve last 2 records when toggle was clicked and display the details, last 2 records as in when the toggle was turned on followed by when it was turned off.

  • BCBuizer Profile Picture
    22,844 Super User 2026 Season 2 on at

    Hi @pujaclb ,

     

    Can you please open a new topic for this question? Like that it will be easier for other members of the community to find the solutions.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard