Is there a way to limit the result in a look-up?
E.g. you've created a purchase order and are now inputting pruchase order lines, but for every new line, you don't what to see the products which are already in the purchase order.
Is there a way to limit the result in a look-up?
E.g. you've created a purchase order and are now inputting pruchase order lines, but for every new line, you don't what to see the products which are already in the purchase order.
Best answer by René W
You can add a view that is used for the look-up, that hides the products that are already in the purchase order.
E.g. if you have the tables:
You can create a ‘look-up’ view such as ‘purchase_order_product’ with the following fields:
the view purchase_order_product looks something like this:
select po.purchase_order_id
, p.product_id
, p.name
from purchase_order po
cross apply product p
where not exists
(
select 1
from purchase_order_line pol
where pol.purchase_order_id = po.purchase_order_id
and pol.product_id = p.product_id
)
This query cross applies all ‘products’ on the purchase order, excluding those which are already attached to the purchase order. Add this view as the look-up (with the purchase_order_id as reference) and you’re done.
Little sidenote: From a user point of view it might be more confusing they don't see their products. A warning / constraint that a product cannot be added twice can solve the issue as well.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.