cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
roncam
Level: Powered On

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
ChrisRoxor
Level: Powered On

Re: add timestamp to an already created item

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
ChrisRoxor
Level: Powered On

Re: add timestamp to an already created item

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?

roncam
Level: Powered On

Re: add timestamp to an already created item

insert current time

ChrisRoxor
Level: Powered On

Re: add timestamp to an already created item

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.

roncam
Level: Powered On

Re: add timestamp to an already created item

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.

roncam
Level: Powered On

Re: add timestamp to an already created item

obviously updating the current record

ChrisRoxor
Level: Powered On

Re: add timestamp to an already created item

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

roncam
Level: Powered On

Re: add timestamp to an already created item

ThisItem is not working

ChrisRoxor
Level: Powered On

Re: add timestamp to an already created item

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 Team
Community Support Team

Re: add timestamp to an already created item

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 304 members 3,227 guests
Please welcome our newest community members: