Picklist Lookup

Q:
how to implement a picklist for a FK field in a table inside a form and grid section.
A:
Use the Choices attribute and specify a SQL Select statement. For numeric fields, use the Choices + Get data mapping / Set data mapping as demonstrated in the example_datamapping App.

Taking the southwind orders table as an example, it contains the customerid field, e.g. ‘ALFKI’. For that, I would just use choices – select customerid from customers – and include an ‘order by’ or ‘where’ clause if required. The orders table also has employeeid. If I wanted to display the lastname of the employee, rather than their id, I would use data mapping to display the lastname (Get data mapping) and my select statement would be based on the lastname. I would use the Set data mapping to store the employeeid for the selected lastname back to the table.

So if you just want to display a choice list, just use choices and if you want to display a name or a description associated with an id (another field in the lookup table), use the get/set data mapping as well.



Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s