Only Lookup must work

omyvadiya
Member Posts: 124
Hi,
I have written a lookup code on a field, but if user types, it isn't validating the data that is being typed.
Somehow, it can be that either the written text is validated from the page that is opening on lookup or writing anything is not allowed??
I have written a lookup code on a field, but if user types, it isn't validating the data that is being typed.
Somehow, it can be that either the written text is validated from the page that is opening on lookup or writing anything is not allowed??
0
Best Answer
-
Its done.
Just have to use the below kind of code for such cases:
IF "Account Type" = "Account Type"::"G/L Account" THEN BEGIN
GLAccount1.INIT;
IF "Account No." <> '' THEN
GLAccount1.GET("Account No.");//Over here it will give u the error, where it checks it existence..still i guess, how it will work for non primary keys??
END;
0
Answers
-
Its done.
Just have to use the below kind of code for such cases:
IF "Account Type" = "Account Type"::"G/L Account" THEN BEGIN
GLAccount1.INIT;
IF "Account No." <> '' THEN
GLAccount1.GET("Account No.");//Over here it will give u the error, where it checks it existence..still i guess, how it will work for non primary keys??
END;
0 -
Your code looks strange to me. I don't know where you placed that code, though.
Nevertheless, there are two fundamentally different kinds of lookup triggers, those on table fields, and those on controls on Pages.- In the OnLookup trigger of a table you always should use VALIDATE to set the field's value.
... IF PAGE.RUNMODAL(0,MyRec) = ACTION::LookupOK THEN VALIDATE(MyField,MyRec.Code);
- In the OnLookup trigger of a page, you should always assign the value to Text and return TRUE. Lookup then just fills in the value into the control, and normal processing occurs when you leave the control, just as if you entered the value from the keyboard. This behavior is identical to a field for which you just set the TableRelation property and NAV is using the LookupPageID of the related table. You cannot achieve the same behavior when using a lookup trigger implemented on the table field.
... IF NOT (Page.RUNMODAL(0,MyRec) = ACTION::LookupOK THEN EXIT(FALSE); Text := MyRec.Code; EXIT(TRUE);
0 - In the OnLookup trigger of a table you always should use VALIDATE to set the field's value.
-
My motive was to stop users from writing any text, instead they must open the page and select the values. And .GET did that0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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