What I’m trying to do:
I created a table called journal_types with a column “types” and another column called “lines”
In the server module I put a function to search journal_types
def get_journal_types():
return app_tables.journal_types.search()
In my form I then created a drop down which lets the user select from the types column:
self.journal_type_dd.items = [(r[‘types’], r) for r in anvil.server.call(‘get_journal_types’)]
using the feedback form example I came up with:
#list all fields that will be updated when submit button is clicked
journal_type=self.journal_type_dd.selected_value
date=self.date_box.date
name=self.name_box.text
email=self.email_box.text
description=self.description_box.text
to extract data submitted by the form.
I would like to select a value from “lines” column in the journal_types table from the specific row having the value selected in the dropdown
What I’ve tried and what’s not working:
journals_row = app_tables.journal_types.get(types=journal_type)
lines=journals_row[“lines”]
& get this error:
anvil.tables.TableError: Column ‘types’ can only be searched with a string (not a Row from ‘Journal_Types’ table) in table ‘Journal_Types’
However if manually choose a specific value in the code I get no errors eg
journals_row = app_tables.journal_types.get(types="Cash Sale")
lines=journals_row["lines"]
Is there a way to link the output of this code depending on the item chosen by a user in the dropdown menu?
Code Sample:
# this is a formatted code snippet.
# paste your code between ```
Clone link:
share a copy of your app