Try this:
# this join limits the auth_user result set to those users who are also in
the tech table
query = (db.helpdeskTech.userid=db.auth_user.id)
# IS_NULL_OR is deprecated
ticket.assignedTo.requires = IS_EMPTY_OR(
IS_IN_DB(db(query), 'auth_user.id', '%(first_name)s %(last_name)s'
)
On Monday, May 7, 2012 4:37:46 PM UTC-4, Jim S wrote:
>
> Hi
>
> I am having trouble getting my list to display the way I want it to.
>
> Given the following definition:
>
> -----------------------
> helpdeskTech = db.define_table('helpdeskTech',
> Field('helpdeskTechId', 'id', readable=False),
> Field('helpdeskId', db.helpdesk, required=True, label='Helpdesk'),
> Field('userId', db.auth_user, required=True, label='User'),
> format='%(userId.lastFirst)s')
> helpdeskTech.helpdeskId.requires = IS_IN_DB(db, db.helpdesk,
> '%(name)s',
> zero='...choose...')
> helpdeskTech.userId.requires = IS_IN_DB(db, db.auth_user,
> '%(lastFirst)s',
> zero='...choose...')
> helpdeskTech['_plural'] = 'Technicians'
>
> ticket = db.define_table('ticket',
> Field('ticketId', 'id', readable=False),
> Field('helpdeskId', db.helpdesk, required=True, label='Helpdesk'),
> Field('name', length=100, required=True),
> Field('description', 'text'),
> Field('createdOn', 'date', label='Created'),
> Field('createdBy', db.auth_user, required=True, label='Creator'),
> Field('assignedTo', db.helpdeskTech, label='Assigned To'),
> Field('priority', length=10, required=True),
> Field('status', length=10, required=True),
> format='%(name)s')
> ticket.helpdeskId.requires = IS_IN_DB(db, db.helpdesk,
> '%(name)s',
> zero='...choose...')
> ticket.name.requires = IS_NOT_EMPTY()
> ticket.createdOn.requires = IS_DATE('%m/%d/%Y')
> ticket.createdBy.requires = IS_IN_DB(db, db.auth_user,
> '%(lastFirst)s',
> zero='...choose...')
> ticket.assignedTo.requires = IS_NULL_OR(IS_IN_DB(db, db.helpdeskTech,
> zero='...choose...'))
> -----------------------
>
> I want my IS_IN_DB validator in the last line to display the last name
> and first name from the auth_user table.
>
> But, what I'm getting is the helpdeskTechId field displaying.
>
> I'm wondering how I can refer back to the auth_user table to get the
> names to display in the dropdown instead of the helpdeskTechId without
> custom-coding the view.
>
> Thoughts?
>
> -Jim
>
>
>
>