hi all, i need some help on lookup
the objective : i need to put some additional filter on "No." field on "Sales Line" table during lookup, so the list only shows a specific set of filtered item for respective user (based on their access level).
(as far as i know) it's impossible to put such filter algorithm in the default lookup functionality (on the TableRelation property).
thus, i create my own code on the "Sales Order Subform." form on the "OnLookup" event.
the issue is, after i override the the OnLookup event with my code, the other events (e,g : OnValidate, OnAfterValidate) are not triggered.
i thought, maybe i did something wrong on my code. so i try to put a very simple code such as
MESSAGE('TEST');
but the result still same, the event stops on the Onlookup. I have to trigger the OnValidate manually using VALIDATE function.
but it's not the solution, there is another default event that need to be triggered (OnAfterValidate)...
so, the question :
1. is it a default NAV behaviour? the manual event will stop the trigger chain?
2. if it's not, where did i do wrong?
3. Is there any way for me to achieve my objective (to put the additional filter on the "Item List" during lookup) without stop the trigger chain?
hope there's a solution for this
Comments
i found a workaround by using sendkeys function to simulate F2 keypress after onlookup.
but i still wondering, is there any better ways to do this?
I thin the csde you wrote in OnLookUp Trigger is similar to this
case type of
type::item:
begin
clear(FItemList);
Clear(TItem);
TItem. sertrange( all filters you need);
FItemList.lookUpMode:=true;
FItemList.editable:=false;
FItemList.settableview(TItem);
If FItemList.runmodal= Action::LookUpOk then
begin
FItemList.getRecord(TItem);
rec."no.":=TItem."No.";
rec.validate("No."); // I Think this is the instruction you nedd.
end;
end;
Remenber that if you wrote code for Items, you must Write code for the rest of Type field values, G/L Account, ....
Bye
As Saalek says, you should validate your field. For your OnValidate and OnAfterValidate code of your form to run, you should also write them after your validation code.
Dynamics NAV Developer since 2005
Rmember: use the triggers on the form only for specific functionality of the form (mainly connected to the visualization of the data), not for data processing...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.