Sorry for the lazy example, I have to go, I can try to write the proper
code if you didn't solve it tomorrow, just ask.

Richard

On Mon, May 7, 2012 at 5:36 PM, Richard Vézina
<[email protected]>wrote:

> Ok, now I understand...
>
> You should allways use id instead of name or other field. Anyway I think
> you can figure it out from this example :
>
> dog
> name
> person_id
>
> person
> name
>
> stat_about_dog_and_person
> stat1
> stat2
> dog_name
> person_name
>
> If I want to get dog_name or person_name in
> stat_about_dog_and_person.dog_name
>
> I could something like this :
>
> db.dog(ID).name
>
> You just have to replace the ID by the id or a query that return the id...
> You can even do : db.dog(db.auth_user(db.ham(ID).id)).id).name
>
> Richard
>
> On Mon, May 7, 2012 at 5:09 PM, Jim Steil <[email protected]> wrote:
>
>>  Sorry, not sure I follow.
>>
>> In my example, helpdeskTech is a subset of auth_user.  My 'ticket' has a
>> helpdeskTechId (in the assignedTo field), not an id from the auth_user
>> table.  I want my select tag to display the auth_user name, but return the
>> helpdeskTechId from the helpdeskTech table.
>>
>> Maybe I don't fully grok the IS_IN_DB and the way the parms work.  I'll
>> go back and look that over again.
>>
>>     -Jim
>>
>>
>> On 5/7/2012 3:59 PM, Richard Vézina wrote:
>>
>> auth_user_rows = db().select(db.auth_user.id)
>>
>>  make a set :
>>
>>  auth_user_set = ((db.auth_user.id ==  rows.first().id)|(db.auth_user.id==  
>> rows.last().id))
>>
>>  IS_IN_DB(auth_user_set,...)
>>
>>  Richard
>>
>> On Mon, May 7, 2012 at 4:37 PM, Jim Steil <[email protected]> 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
>>>
>>>
>>>
>>>
>>
>

Reply via email to