filter portal in FMP 10 older -
04-02-2010
, 12:38 PM
I found a way to filter an order's line items portal, but I'm not sure
if there's an easier/better way. Here's the tables:
ProductType
TypeID
Products
ProductID
TypeID (foreign key)
Orders
OrderID
g_TypeFilter
LineItems (join table)
OrderID (foreign key)
ProductID (foreign key)
Since the list of line items can grow longish, I want to filter the
portal by type: Show me the items ordered, but only if the product type
is [xy].
I thought this should be rather simple, but I couldn't get my mind round
it. I need to go from the orders to the line items, the line items table
doesn't have a type field. If I used a calc field to display it, it
couldn't be indexed and the relation wouldn't work. I'd have to use a
data field for the type, filling it with auto-enter and create redundant
data.
In order to avoid this, I put a global field for the type in the order
table and added a calc field that used the list function to
a) get all the ProductIDs of a type if there is something in the field
g_TypeFilter
b) get all the ProductIDs of the ordered items if there's nothing in the
field g_TypeFilter.
Now I use this g_TypeFilter field together with the OrderID on the left
side of the relation that drives the portal.
Haven't tested the performance on the server, and anyway: the list
function came with FMP9, people must have solved problems like this
before that: is there something obvious I overlooked? Apart maybe form
forcing users to stick to one type per offer?
--
http://clk.ch |