What are you trying to do? Do you want to store this information in the POrequest table, or do you want to prevent inserts if the item is not in the db.inventory table? If the latter, IS_IN_DB will certainly work, but note that validators only get run if you are using SQLFORM or if you call .validate_and_insert().
Anthony On Thursday, February 11, 2016 at 6:02:16 PM UTC-5, Greg White wrote: > > I should have mentioned that I tried IS_IN_DB first off and it didn't work > > On Wednesday, February 10, 2016 at 4:25:48 PM UTC-7, Dave S wrote: >> >> >> >> On Wednesday, February 10, 2016 at 2:01:52 PM UTC-8, Greg White wrote: >>> >>> Want a computed field to show whether or not a field value exists in >>> another table >>> >> >> >> I'm not sure that is the right approach. I think that the standard >> validator IS_IN_DB() is what you want, instead. >> >> <URL: >> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators >> > >> (IS_IN_DB is the second validator in that section) >> >> The example shown appears to be similar to what I think you're trying to >> do. >> >> /dps >> >> >>> started with this... >>> >>> db.define_table( >>> 'inventory', >>> Field('name'), >>> Field('qty', label='Quantity'), >>> Field('MatSize',label='Material Size'), >>> format = '%(name)s') >>> >>> db.define_table( >>> 'POrequest', >>> Field('name', 'reference requestor', label='Requestor'), >>> Field('JobNum', 'reference jobs', label='Job #'), >>> Field('description', 'text', notnull=True), >>> Field('InInventory', compute=lambda r: r['description'] IN r[ >>> db.inventory.name]), <<< this row right here is what I need help with >>> format = '%(name)s') >>> >>> trying to verify row by row in a computed field if >>> db.POrequest.description is in any row of db.inventory.name >>> >>> help please. >>> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.