cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

add timestamp to an already created item

hi,

 

I already created an item in an sp using powerapps and now I need to create two button to insert the start time and end time to this same item.

 

can you help me please ?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

You need to have a selected item before you can modify it. Generally if you have a gallery edit page you would pick the item through the Gallery selection page, and then ThisItem should work. 

If you need to run it as a standalone button without already having pulled the relevant row from SharePoint, you would need to use a function to search by ID or another column with a unique value, to then patch in the now() value.

View solution in original post

9 REPLIES 9
Highlighted
Advocate I
Advocate I

Do you want to insert the current time/date or do you want a date picker to insert a chosen date to overwrite or add to the sharepoint list?

Highlighted

insert current time

Highlighted

You can use the Now function to pull the actual date/time and insert where needed.

See more here:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-now-today-istoday 

 

For example, you could have a text input field with it's default set to:

If(ButtonClicked, CurrentTime, Parent.Default)

This ensures you get the fresh details, but that it will show any preentered details that might be present beforehand.

 

Then the button OnSelect properties

UpdateContext({CurrentTime: Now()});UpdateContext({ButtonClicked: True})

 

Then whenever you click out, you can update the ButtonClicked to False or Blank() to cancel it out.

 

I'm sure there might be a "prettier" way but it should work for you.

Highlighted

i would like to have a button called "Start" when pressed it will update the record with now() time under a particular column in sp and another button named "End" and when pressed will insert the Now() time in another particular column in sp.

Highlighted

obviously updating the current record

Highlighted

Okay so you're trying to just update directly in sharepoint, and not in a text input field.

 

You need to use the Patch function in this case:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

 

Syntax:

Patch( DataSource, BaseRecord, ChangeRecord1 [, ChangeRecord2, … ])

 

So you'd use BaseRecord as the current field to update, example ThisItem.Record1 and in ChangeRecord1 you'd put Now()

 

All of this should of course be on the button OnSelect properties

Highlighted

ThisItem is not working

Highlighted

You need to have a selected item before you can modify it. Generally if you have a gallery edit page you would pick the item through the Gallery selection page, and then ThisItem should work. 

If you need to run it as a standalone button without already having pulled the relevant row from SharePoint, you would need to use a function to search by ID or another column with a unique value, to then patch in the now() value.

View solution in original post

Highlighted
Community Support
Community Support

Hi @roncam,

How do you create a new record within your SP list? Using SubmitForm function or Patch function?

Could you please share more details about the data structure of your SP list?

Based on the needs that you mentioned, I think the Patch function could achieve your needs. If you want to update an existing record using Patch function, you must find the record you want to update firstly.

I have made a test on my side, please take a try with the following workaround:

Set the OnSelect proeprty of the "Start Time" button:

Patch(
   "YourSPList",
     LookUp("YourSPList", ID = "List Item ID"), /* <-- Find the existing record you want to update based on List Item ID*/
     {
       StartTimeColumn: Now()
     }
)

Set the OnSelect proeprty of the "End Time" button to following:

Patch(
   "YourSPList",
     LookUp("YourSPList", ID = "List Item ID"),
     {
       EndTimeColumn: Now()
     }
)

More details about the Patch function and LookUp function in PowerApps, please check the following article:

Patch function

LookUp function

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (13,427)