I have a form where I register the type of a vehicle, the brand, the color, plate number, and service, then press save and it is shown on a repeating panel, my objective now is that if I ever filled the form with that data before, if I input the plate number again in the form, it search the table, locate the row with the number plate and autofill the type, brand and color, but not the service, it is too complicated?
https://anvil.works/build#clone:EYYVCSAV7EIDK6BC=FBKUNUHK3P44N6AIE5AHJ4OS
There are tutorials on here for autocomplete which are super cool.
At the end of a long day my brain says Iād probably run with the assumption the database is nowhere near the size of the DVLA data holding and do something like:
Form:
Def VRM_onpressedenter():
VRM = self.VRM.text
Colour, Etc = anvil.server.call('fetchsfuff', VRM)
self.colour.text = Colour
self.etc.text = Etc
Server:
@anvil.server.callable
Def fetchstuff(vrm):
If app_tables.vehicles.search(VRM=VRM) is not none:
Row = app_tables.vehicles.get(VRM=VRM)
Colour = Row['Colour']
Etc = Row['Etc']
Else:
Colour = None
Etc = None
Return Colour, Etc
100% there will be a better way but Iām on hour 15 of being up with the kids and they are BORED.
2 Likes
@anvil.server.callable
Def fetchstuff(vrm):
Colour = None
Etc = None
row = app_tables.vehicles.get(VRM=VRM) # Will raise an exception if multiple rows share a VRM
If row:
Colour = Row['Colour']
Etc = Row['Etc']
Return Colour, Etc
A little twist from someone who also has kid-sourced-exhaustion 
2 Likes
Much obliged! I knew salvation could be found here.
1 Like
what does āNoneā means here? my table will repeat the plate number because is a register of cars in a carwash so there are some frequent clients that will bring the same car on diferent dates, so it will raise the exception?
thank you for taking the time for the answer, im going to try to use this, it gives me an idea of how should i work the problem
1 Like
The None just means itās a car you havenāt recorded the details for before so leaves it blank for you to fill in.
2 Likes
If thatās the case:
@anvil.server.callable
Def fetchstuff(vrm):
Colour = None
Etc = None
rows = list(app_tables.vehicles.search(VRM=VRM))
If len(rows)>0:
row = rows[0]
Colour = row['Colour']
Etc = row['Etc']
Return Colour, Etc
EDIT
Also, not sure how far along your are in developing your application, but you could think of restructuring your data tables, such that you have a data table labeled āvehicles/customer/whatever makes senseā that hold the constant data of the vehicle, so you donāt have to re assign it every time.
Then you could save the transaction in another data table and link it to your customer table.
1 Like
Youāve actually just fixed something which has been bugging me in a project for ages 
1 Like