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 / How to get a time stam...
Power Apps
Unanswered

How to get a time stamp with the time an event is triggered in an app

(0) ShareShare
ReportReport
Posted on by 753

I have an app where I want to assign the date and time to a field that I will write to a SharePoint List, but I want the date and time when I click the Submit button, not when I start the app. I am using the following function in the "Update" property of a logging field:

 

Text(DateTimeValue(Now()), "mm/dd/yyyy hh:mm AM/PM")

 

If I run the app and let it sit for 5 minutes, the date and time saved seems to be when the app started and not when I clicked on the Submit button, which is where I run a "SubmitForm" command.

 

I then decided to use the following command before the "SubmitForm" function in my Submit button:

 

DataCardValue3.Text=Text(DateTimeValue(Now()), "mm/dd/yyyy hh:mm AM/PM") & " - Started"

 

and used the following function in the "Update" property of my DataCard for DataCardValue3:

 

DataCardValue3.Text

 

That gives me no value written back to my SharePoint list, which tells me that somehow, when I clicked on the Submit button, the value was not saved.

 

What do I need to do to get a time stamp for the moment when I submit my form?

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Greg27 

    Every record has a 'Created On' and a 'Modified On' metadata property that is automatically recorded and can be accessed by PowerApps.

  • Greg27 Profile Picture
    753 on at

    @Drrickryp 

    We want to create a log field that we can display on a form history that shows where the form is currently in a workflow. Something similar to the following:

     

    07/29/2022 9:05 AM - Started

    07/29/2022 9:06 AM - Sent for approval to first approver.

    07/29/2022 3:18 PM - Approved by first approver.

    07/29/2022 3:19 PM - Sent for approval to second approver.

     

    That way, the person who is looking at their current form will know where it is in the approval process and knows who to contact if it's taking too long. The problem is that if I can figure out how to get the current date and time as opposed to when I ran the app, this will never work properly.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Greg27 

    Put it in the OnSuccess property of the form.

  • Greg27 Profile Picture
    753 on at

    @Drrickryp 

    Do I put the following function on the OnSuccess property of the form:

     

    DataCardValue3.Text=Text(DateTimeValue(Now()), "mm/dd/yyyy hh:mm AM/PM") & " - Started";

     

    and then set the Update property of the status data card to be DataCardValue3.Text. I tried this and now I am getting nothing written to my SharePoint List.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Greg27 

    I may not understand your requirements.  Do your required a log of every time the form is modified or just a single time of the last modification. If it is the latter, SharePoint captures the exact date and time of the last modification (ie when the form is successfully submitted) automatically and it is metadata that cannot be be changed by the user.  However, it is accessible in the forms as Modified or 'Modified by'.  Here is a record that I modified this morning and saved and then modified it again a few minutes later.   

     1.jpg2.jpg

  • Greg27 Profile Picture
    753 on at

    @Drrickryp 

    I want a log of what happened and when. I.E. in a workflow, the field (Multiple lines of text) would show the following:

     

    07/29/2022 9:05 AM - Started

    07/29/2022 9:06 AM - Sent for approval to first approver.

    07/29/2022 3:18 PM - Approved by first approver.

    07/29/2022 3:19 PM - Sent for approval to second approver.

     

    So, I want one field to show creation date and time and all of the last modified dates and times, including what happened when the SharePoint List was modified. 

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Greg27 

    On that case, since you are dealing with a one to many relationship, I would set up a second list with a foreign key, a description, and a date/time field.

  • Greg27 Profile Picture
    753 on at

    So, there is no way to grab and set the time at the moment I click on a button?

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Greg27 

    The way you are currently designed, you will overwrite your prior settings if you use a single table. I suggest you separate your audit log from the original list.  If you create a Log file as a separate list, referred to below as loglist,  you can use a Patch in your OnSuccess property of the form to enter a new record in the log file that automatically records the date/time and the user who does the approval.  All you would need is the ID of original list, say ParentID and a description. If I were designing it.  I would put a dropdown on the form with the Items :["Original submission", "Sent to 1st approver", "Approved on", "Sent to 2nd approver"].

     

    Patch(
     loglist, Defaults(loglist),
     {ParentID:Form1.LastSubmit.ID, 
     Description:Dropdown1.Selected.Value
     }
    )

     

    The 'Created by' and 'Created on' metadata fields would be automatically created in the loglist  when the Submit button is hit. 

     

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