Pull recent row and display on second form

A new row of data is being added to my data table every time form 1 is submitted. How do I pull the most recent row and display that data in form 2?

Hello,

Would this work for you?

clone:
https://anvil.works/build#clone:HXE237ENSF3Z6GIA=T7K5LV6WNHAU6TTRL5E7ASUS

The app works in the following way:

  • add data to a text box (e.g., a product name) on form 1
  • update the corresponding DataTable
  • fetch the record that was submitted most recently and display it on form 2

If you want to display more records and/or add rows, all on the same form, I would recommend going through the Repeating Panel and DataGrid tutorials if you have not already.

I hope this helps.

4 Likes

Yes, that’s exactly how I wanted my app to run. Thanks a lot

1 Like

A little aide memoir for me, so I can “remind” myself without downloading the app each time.

The key to this is storing a date with the record and fetching the most recent like this :

row=app_tables.products.search(
  tables.order_by(
  'submit_date', ascending=False
  )
)[0]

(I don’t use the data tables enough to remember all the functions).