What I’m trying to do:
I have 4 different buttons and I am using to clock in.
button1 = clock in
button2 = clock out
so on…
I used app_tables.clockinoutsystem.add_row(Clock_In_Start=Start_time_LA_time) for the 1st button, but when I use this same line of code (add_row), for the second button it adds a new row instead of updating the original row. I am sure there is a amend code right to search and find the row you were updating.
I read it, but obviously making a newbie mistake somewhere. Currently trying to update the row I added in def clock_in_button_click.
I keep getting this error and I cannot figure out what I am doing wrong. If I were to guess, def clock_out_button_click probably cannot reference the original row for some reason.
TypeError: ‘NoneType’ does not support item assignment at [Form1, line 74](javascript:void(0))
I am self-taught, but clearly, some of the basics eluded me.
It helps the readability of code if you post it between pairs of three backticks, e.g. ``` That’ll keep the formatting of the code intact.
I can’t really comment on the error message, because I don’t know which line is line 74.
In general, though, if you want to create a row in one function and update that row in another function, you should keep a reference to it around in a self. variable.
So here is where I am stuck at…
I am trying to access the same row in **def clock_in_button_click function(self, event_args) so I can I update that row with the new clock out in def **clock_out_button_click(self, event_args) I made a few changes since we last messaged. The most updated version is the one below.
Currently getting this error
anvil.tables.TableError: More than one row matched this query
So my question is how do I get the same row in one function so I can update it in another function? I need clock in start shift, clock out, clock in, clock out for the day These are DateTime columns in the data table.
That’s the answer to your question. If that doesn’t make sense, you may want to go through the news aggregator tutorial again, since it’ll cover that and other aspects of building an Anvil app that works with data tables.
The larger context of the app is also missing, so it may be that what you’re trying to do isn’t the right way to go about it. Is this supposed to be a multi-user app? A single-user app? Is it used from a single PC that multiple users use, or do multiple users use their own PCs?
More context will help folks give you better general advice, but there’s no substitute for having the technical foundation the tutorials provide.
You may also want to edit the title of your post, since it was never really about getting the current time, it was about updating the original row. That’ll help people who later search the forum looking for current time related posts.
Clocked_In is a local variable, so it (and its value, a reference to the added database row) will be discarded as soon as the function ends. Did you want to retain this value for later use?