What I’m trying to do:
It is my first time coding in a long time and I’m am very new to Anvil so please forgive me if I am making very simple mistakes that I have overlooked.
I am creating a time management app for school and I have saved user time schedules into a database along with a UUID. I am trying to search for the UUID in the database by showing the user all their saved schedules and then using that UUID display those in a separate form by saving the uuid in a separate form.
What I’ve tried and what’s not working:
I’ve managed to display the saved schedules from the user but whenever I am getting the uuid from the selected schedule that the user wants to display it always returns as a live object search iterator. And when trying different methods I’ve found other errors such as: ‘anvil.tables.TableError: Column ‘uuid’ can only be searched with a string (not a simpleObject) in table ‘Schedules’’. Either way my end goal of displaying this schedule has not worked out yet
Code Sample:
#server module
@anvil.server.callable
def get_schedule_id(subject, as_number):
if anvil.users.get_user() is not None:
result = [{subject: r["Subject"], as_number: r["as_number"]} for r in app_tables.schedules.search()]
return result
#calling form
def schedule_select_click(self, **event_args):
"""This method is called when the link is clicked"""
Globals.selected_schedule = self.schedule_title.text
Globals.schedule_as_number = self.schedule_as.text
uuid = anvil.server.call('get_schedule_id', Globals.selected_schedule, Globals.schedule_as_number)
uuid = Globals.selected_schedule_id
alert(content=schedule_show(), large=True)
There is also the displaying of the schedule where I am using a repeating panel and binding each of the labels in the repeating panel to a certain part of the schedule that I should be retrieving through the uuid:
class schedule_show(schedule_showTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
self.refresh()
# Any code you write here will run before the form opens.
def refresh(self):
# schedule = anvil.server.call('schedule_by_id', Globals.selected_schedule_id)
self.schedule_panel.items = anvil.server.call('schedule_by_id', Globals.selected_schedule_id)
Please let me know how useful it would be for me to share a copy of my app because I would need to omit quite a lot of stuff first!
Thanks in advance