Hello everyone. I’m a complete Anvil newbie having created my account just today. I’ve spent time going through the tutorials, the reference guide and searching just a bit on the forum. My apologies in advance if I’m asking super basic questions. If you feel I haven’t done enough homework, please just let me know and maybe give me a place to start looking and I’ll get to it!
I’m starting my first app and creating the necessary tables using Anvil tables. I am trying to link a few tables. I set up the link when adding the field. When I add a new row via the IDE, I am prompted to select the row as I would expect. This was super easy and fast. Yeah!
However, when I look at the row of data, under the field where it’s linked to the other table, it says “Unnamed Row” My question is, is this what it should say? I would have thought it would have inserted some part of the linked row as it did with the first table which is also linked.
So far I have three tables.
Org is a table with just a list of organizations.
fy is a table which has a year and is linked to the organization. Each organization may have a number of different years.
coa is a table where I want to link back to the fy table to pull in a year for a specific organization. In other words, if you look at the example below, each organization may have the year 2018, and for each organization, they may have many categories for that year. In fact, they may have the same categories for each year in the fy table. I.e., an organization could have a “supplies” category for year 2018, 2017, and 2016, etc.
I’m not sure what the “unnamed row” indicator is telling me. Before I go any further, I want to make sure my table set up is correctly. Any help is much appreciated.
Hi there, and welcome to the forum! Looks like your tables are set up right - you have a list of organisations, and multiple financial years for each org, and a ‘coa’ row each of which is associated with an organisation’s financial year, right?
“Unnamed row” is what the Anvil table editor displays when it doesn’t know how to summarise a row. Normally it picks the first Text column (eg it’s picked the name column from the “Org” table), but looks like it got confused by the fact that the “fy” table starts with a number. This doesn’t affect anything except how the rows appear in the table editor itself. This is a sensible table structure, and the tables themselves will work just fine in your app.
Hello all. I’m not sure if this should have been placed in its own post, however, it seems my issue is a continuation of this conversation about “Unnamed row”
I have a table named truck_check_in; made up of mostly links to rows in several tables, a date and time field, a few Booleans and one text field called notes. It has become necessary to create a separate notes table which will link to a row from the truck_check_in table, which means I will be removing the only text field once I complete my testing.
While adding a new row to the notes table, I noticed if the truck_check_in.notes field is Null, the linked field value on the notes table appear as “Unnamed row” for the new note. If there is text in truck_check_in.notes then the link to the row is stored with the correct link to the row in the truck_check_in table.
Does anyone have any suggestions to get around this issue without having to include a note or other text field in the truck_check_in table?
Hi, welcome to the Forum! Yes, your question does seem relevant to this thread
The “Unnamed row” gets displayed because Anvil tries to name the Row using the first text field, but if the Row is empty, Anvil displays it as “Unnamed”.
The links are still correct (unless there’s a bug) - if you do
for row in app_tables.truck_check_in.search():
print(row['notes'])
You’ll find that the links do point to existing rows.
If you want to get rid of the ‘Unnamed row’, you will have to include a ‘placeholder note’ or another column called something like ‘id’.
You can generate an auto-incrementing ID row using a couple of lines of Python when you add new rows:
@anvil.server.callable
def add_rows():
highest_id_row = app_tables.notes.search(tables.order_by('id', ascending=False))[0]
latest_id = int(highest_id_row['id'])
for i in range(10):
latest_id += 1
app_tables.notes.add_row(notes=None, id=str(latest_id))
I’ve had a moment to look further into your suggestion Shaun. Since the “Unnamed row” link is pointing to the correct existing row, I don’t think the id field will be necessary in my scenario.
Thanks again for your explanation, suggestions and time. It is greatly appreciated!!