Using TypeAhead fields and returning a Primary Key

I would like to be able to use a typeahead field (very handy for lookups) and then get the Primary Key (index) that the user chooses from the list … i.e., for the chosen item in the typeahead field:

Assume PK is type integer and is = 12869;
Value the user chooses is = ‘A generic looking string’ (the string itself is not unique in the field)

I see how the value the user chooses from the typeahead is dropped into the field itself. Is there a way to grab the PK integer 12869 at the same time? I know how to do this with a valuelist and a db lookup.

Thanks

Michael

I’m not sure to understand your problem.
If you set a value list to dispaly your string but return your PK, your users can select by typing ahead the string and the PK is returned in the DB.
If you mean that AFTER the selection you want to see in your form just the PK you can place another uneditable istance of the same field in your form without any list attached to show the PK like this:

| PK_field | | PK/String Field |

Once the value is selected it will lokk like this:

| 002 | | Apple Computer Corp. |

Nicola,

And does the technique you are commenting on work ok with typeahead fields?

I noted that one can bind the valuelist to the typeahead field.

Thanks

Michael

Maybe I wasn’t clear in my explanation, you have to put two fields in your form like this:

| 002 | | Apple Computer Corp. |

The first field is a not editable text field and has PK as dataprovider and no valuelist attached.
The second field is a typeahead field, has PK as dataprovider and a valuelist attached; the value list should display “company_name” and return “PK”.

Your users can click and type on the second field, select the company by name and after all is finished you will have in your forms the ID and the name of the company.

Hi Michael,

Michael Mooney:
Value the user chooses is = ‘A generic looking string’ (the string itself is not unique in the field)

(emphasis is mine)
One question. How do you know what PK you should use when the string is not unique ?
A type-ahead valuelist will show only the unique values. So one value can represent 1 or more PK’s.

Sounds to me that a type-ahead field is not the way to go with this.

Hi Robert,

I don’t know the PK - precisely my problem (I can do this thing fine with a db seeded ValueList and say a ComboBox).

However, I have seen (on other systems with rave user reviews) a TypeAhead field that allows the user to do the “type ahead thing” and drill down into the database. Once the user clicks on the record they want, the system is aware of the descriptive (user friendly) field chosen AND as well the background PK of the selected item.

Imagine if I have an Inventory system and I want to use typeahead to drill down into product names and select a record. Once located, then I want to know the PK so I can do some things programmatically (for example, output the Product SKU to screen or whatever …).

I know users love screens that do this sort of thing … I am wondering if there is a way to do this at 3.5 rc 2.

Thanks, Michael

Hi Michael,

I just did a test and you can make it work the following way:

Create a valuelist that returns the PK but shows the text.
Now connect this valuelist to a field with the displaytype set to TYPE_AHEAD.
Now when you type in this field you see indeed duplicate names so maybe you want it to display a second string value as well that explains it more.
When you hit enter the type ahead field does show the selected text BUT the value stored in the field is in fact the PK.
I.e. just like it would with a combobox.

If you don’t want to see all those duplicate values in the type ahead field then maybe you should use this field to fill a foundset with matching records in a list/table view after you hit enter. Of course you need to make the valuelist only show and return the text data.
Then the user can see more then one column of the data as well and can make the correct selection of the data.

Hope this helps.

Robert,

Appreciate the suggestion - will give it a try shortly!

Michael