Problem with custom lookup

tompynation
Member Posts: 398
Hi, in the purchase order subform i added following code to the lookup trigger of the Item No. field:
IF Type = Type::Item THEN BEGIN
lv_Item.RESET;
lv_Item.SETRANGE(lv_Item."Vendor No.",gv_VendorCode);
IF FORM.RUNMODAL(31,lv_Item) = ACTION::LookupOK THEN BEGIN
VALIDATE("No.",lv_Item."No.");
END;
END;
I fill up the gv_VendorCode like this:
Form - OnAfterGetCurrRecord()
IF "Buy-from Vendor No." <> '' THEN
CurrForm.PurchLines.FORM.SetVendorFilter("Buy-from Vendor No.");
So this makes sure that when i use the lookup i only see the items from that Vendor... When the user press the show all he see's all items.
This works fine but when i try to select an item i get following error:
There is no Item within the filter.
Filters: Vendor No.: '', No.: XXXXXX
XXXXX is the item number that i selected through the lookup...
Anyone knows whats going wrong now?
IF Type = Type::Item THEN BEGIN
lv_Item.RESET;
lv_Item.SETRANGE(lv_Item."Vendor No.",gv_VendorCode);
IF FORM.RUNMODAL(31,lv_Item) = ACTION::LookupOK THEN BEGIN
VALIDATE("No.",lv_Item."No.");
END;
END;
I fill up the gv_VendorCode like this:
Form - OnAfterGetCurrRecord()
IF "Buy-from Vendor No." <> '' THEN
CurrForm.PurchLines.FORM.SetVendorFilter("Buy-from Vendor No.");
So this makes sure that when i use the lookup i only see the items from that Vendor... When the user press the show all he see's all items.
This works fine but when i try to select an item i get following error:
There is no Item within the filter.
Filters: Vendor No.: '', No.: XXXXXX
XXXXX is the item number that i selected through the lookup...
Anyone knows whats going wrong now?
0
Answers
-
I cannot understand why you put the C/AL code in the subform and not on the table 39.
Marco0 -
Where would i add the code inside the Purchase Line table?
I dont want to change the lookup functionallity in other forms... Just on the Purchase Form.0 -
On the OnLookup trigger of the "No." field, but in any case if you specify what you want to do, then we can help you in a more precise way...0
-
Well, i just want that when a user is inserting a purchase order line(s)
that when he looks up the item, that first the lookup form only shows the items who have the corresponding Vendor No with
the buy from Vendor no. on the header.
But by pressing show all he should also be able to select items who dont have the Vendor No equally to the Buy from Vendor No.0 -
SetVendorFilter("Buy-from Vendor No.");
-what does this function do?
-after pressing "show all", are you selecting an item for a vendor which is different from the one in the header?
-But by pressing show all he should also be able to select items who dont have the Vendor No equally to the Buy from Vendor No.0 -
allright i got it working like i wanted it now...
The problem was something that i created myself to test:
IF (Type=CONST(" ")) "Standard Text" ELSE IF (Type=CONST(G/L Account)) "G/L Account" ELSE IF (Type=CONST(Item)) Item WHERE (Vendor No.=FIELD(Buy-from Vendor No.)) ELSE IF (Type=CONST(3)) Resource ELSE IF (Type=CONST(Fixed Asset)) "Fixed Asset" ELSE IF (Type=CONST("Charge (Item)")) "Item Charge"
This is the table relation property of the No. field in the Purchase line table.
Putting it back to the original solved the problem
IF (Type=CONST(" ")) "Standard Text" ELSE IF (Type=CONST(G/L Account)) "G/L Account" ELSE IF (Type=CONST(Item)) Item ELSE IF (Type=CONST(3)) Resource ELSE IF (Type=CONST(Fixed Asset)) "Fixed Asset" ELSE IF (Type=CONST("Charge (Item)")) "Item Charge"0 -
Belias wrote:
SetVendorFilter("Buy-from Vendor No.");
-what does this function do?
-after pressing "show all", are you selecting an item for a vendor which is different from the one in the header?
-But by pressing show all he should also be able to select items who dont have the Vendor No equally to the Buy from Vendor No.
This function just fills up a variable inside the subform... Its the gv_VendorCode that it fills up to filter the lookup form.
When users presses "Show all" he is able to select an item which Vendor No. does not equal the Buy From vendor No. on the Header. So standard NAV functionallity.
It works fine now but if you guys have better solution, i'm ready to implement0 -
i cant get it to work with the table relation...0
-
allright, so my first solution is good0
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