StrataFrame Forum

Using the Seaching Browse Dialog event to filter by sub query

http://forum.strataframe.net/Topic32117.aspx

By Govinda Berrio - 6/21/2013

Hello all, 

I am wondering if anyone can submit an example of using the BrowseDialogSearchingEventArgs.Tokens to add the results of a subquery. 

The situation that I would like to handle is: the user is on an Orders screen and they want to search for an order with a particular Product in it. If I used a view for the Browse Dialog that joined Orders and OrderItems I would get multiple rows if I just searched by the Order ID. Since I only want to show a list of orders, I figure the solution would be to use a sub-query (SELECT OrderId FROM OrderItems WHERE OrderItems.item_id = ?). 

From some other threads here and the description of the Tokens property, this should be possible. But I do not know where to start, so I was hoping someone could provide a simple example of using Tokens to inject the sub-query results into the Browse Dialog Search results processing. 

Thank You, 
Govinda 
By Ivan George Borges - 6/22/2013

Hi Govinda.

Maybe you could have 2 BrowseDialogs in your form. One for the Orders, and this could have Order Number, Client, Date, etc., as SearchFields and would search on the Orders table, and the other BD could have the OrderItems SearchFields including the Product and would search the OrderItems table.
For this second one, you could add a BrowseDialogClosed event handle and use the populated OrderItems BO to get the Orders primary key that returned with it. After that, you just populate your Order BO and the user will have it on the form.

Hope it helps.