PROBLEM : Custom Lookup stop the trigger chain
andrea_djunaidy
Member Posts: 8
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
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
0
Comments
-
UPDATE :
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?0 -
Hi
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, ....
Bye0 -
Saalek wrote:Hi
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.Cem Karaer @ Pargesoft
Dynamics NAV Developer since 20050 -
Question is, isn't the code on the form wrongly placed? Dou you really use these triggers on the form? Shouldn't be the code in OnValidate on the table?
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...0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

