Create Lookup Functionality with code

StephenG
Member Posts: 99
Hi,
I'm trying to create the standard lookup functionality with code :?
ShipToCodeFilter Text variable on the RequestOptionsForm.
ClearOnLookup = NO
ValidateTableRelation = No
What I'm trying to do is that depending on whether the text in the textbox (where I start my lookup from) is selected, the action either overwrites the existing text (if the text was selected), or appends the newly looked up value behind the cursor.
So, if I have "Addr1.." in a textbox and do a lookup to Addr2, then my textbox should read "Addr1..Addr2" ONLY if "Value1.." was not selected (highlighted). If "Addr1.." WAS selected, my textbox should overwrite "Addr1.." with "Addr2", rather than append to it.
This is in a Financials 2.01 database.
I'm trying to create the standard lookup functionality with code :?
ShipToCodeFilter Text variable on the RequestOptionsForm.
ClearOnLookup = NO
ValidateTableRelation = No
TextBox ShipToCodeFilter. OnLookup(VAR Text : Text[250];) : Boolean IF CustNoFilter = '' THEN ERROR('You must select a customer No. if you want to filter on Ship-to Code'); ShiptoAddress.SETFILTER("Customer No.",CustNoFilter); IF FORM.RUNMODAL(0,ShiptoAddress,ShiptoAddress.Code) = ACTION::LookupOK THEN BEGIN IF ShipToCodeFilter <> '' THEN ShipToCodeFilter := ShipToCodeFilter + ShiptoAddress.Code ELSE ShipToCodeFilter := ShiptoAddress.Code; ShipToCodeFilter := UPPERCASE(ShipToCodeFilter); END;
What I'm trying to do is that depending on whether the text in the textbox (where I start my lookup from) is selected, the action either overwrites the existing text (if the text was selected), or appends the newly looked up value behind the cursor.
So, if I have "Addr1.." in a textbox and do a lookup to Addr2, then my textbox should read "Addr1..Addr2" ONLY if "Value1.." was not selected (highlighted). If "Addr1.." WAS selected, my textbox should overwrite "Addr1.." with "Addr2", rather than append to it.
This is in a Financials 2.01 database.
Answer the question and wait for the answer.
0
Comments
-
Hi Stephan
If I got it right, I have solution to your problem.
I will setup the situation as ---
TextBox -- On which lookup is needed
LookupForm - Form on which lookup is made
LookupSource - source table of lookup form
GetValue -- A getter function in LookupForm that returns selected value (Address in ur case)TextBox : OnLookup LookupSource.reset; LookupSource.setfilter( ........... ); LookupForm.settableview ( LookupSource ); LookupForm.lookupmode := true; if LookupForm.runmodal = action::lookupOK then TextBox := TextBox + LookupForm.GetValue; clear( LookupForm )
I Hope this helps.
Regards,
Jyotsna Sonawane
Navision Developer______Doubt is the father of Invension_______0 -
Guys,
You are forgetting to return a value!
Following trigger can be found on a form.Field - OnLookup(VAR Text : Text[1024];) : Boolean
It's very important you don't fill any fields from this trigger. the only thing you can fill is the Text variable. Don't go validating triggers from this trigger. Plus the function needs to have a boolean returned to know if you found a value or pressed the cancel button.Field - OnLookup(VAR Text : Text[1024];) : Boolean rec.setcurrenkey(foo,bar); rec.setrange(foo,bar); rec.setrange(bar,foo); if form.runmodal(0,rec) = action::lookupok then begin text := rec.foo; exit := true; end else exit := false;
Code have not been tested!
OOooh and do go generating errors from this trigger. This trigger should always start and finisch, return 2 variables."Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."0
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