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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Capture start time and...
Power Apps
Unanswered

Capture start time and end time of a status on click of button

(0) ShareShare
ReportReport
Posted on by 58

Hi All, 

 

I am developing a production tracker, which captures the status of production when the user clicks a button. What i am looking  for is to capture start time of a status (Unavailable) in start_time  column and when the user changes the status to busy after clicking the button, it should capture the end time of the status in end_time column, but it should be for the same record. Once done, the start_time of the new status should get captured as new line item. 

I am using teams dataverse as database.  Image for reference as to how i would like the output. 

If the status is unavailable, then it will capture the start time, but when user changes the status using a click of button, it should capture the end time of 1st status and create a new entry in next line with start time captured for the new status and this continues.

luaxs4_0-1699761969004.png

 

I have the same question (0)
  • Drew Poggemann Profile Picture
    9,287 Most Valuable Professional on at

    Hi @luaxs4 ,

    When the user clicks the button (OnSelect property), you would want to execute the Patch to update the current record.

    Patch(
     StatusTable,
     SelectedRecord,
     {
     end_time: Now()
     }
    )

     

    and then create your new StatusTable record

    Collect(
     StatusTable,
     {
     status: StatusField.Text,
     start_time: Now(), // You might want to have set a variable on what you set as the end from the last record and use this for start so it matches vs. calling Now again...
     end_time: Blank() 
     }
    )

     

    You would want to set the context of your SelectedRecord to the new record you just created as well in case the. user hits the button again...

     

  • luaxs4 Profile Picture
    58 on at

    The " SelectedRecord" is causing some confusion, everytime i tried typing selectedRecord, it shows Name isn't valid "SelectedRecord" isn't recognized error 

     

    luaxs4_0-1699865911776.png

    And If i try defaults option then the record comes in the following manner

    luaxs4_1-1699865977995.png

    what am i doing wrong?

  • Drew Poggemann Profile Picture
    9,287 Most Valuable Professional on at

    Hi @luaxs4 ,

    You are modifying a record so you would need to select this record from the Dataverse to update it.  Example is you could set the selected record from a Gallery or use the Lookup function to find that record...  You can then "Set" the value of the SelectedRecord:

    https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-set 

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard