filter Rec using fieldref
dsatria
Member Posts: 80
How do we put filter on Item Card form using C/AL code?
I tried this but not work:
My plan is to make a dynamic filter based on field/value defined on other table.
I tried this but not work:
lRecRef.gettable(rec);
lfldref:= lrecref.field(fieldno("Vendor No."));
lfldref.setfilter('10-0085');
lrecref.settable(rec)
My plan is to make a dynamic filter based on field/value defined on other table.
0
Comments
-
Before SETTABLE you must process a classical RecRef.FIND('-') so that the RecRef points to the filtered Rec using the Filters on its referenced FieldRefs. After that you can do the SETTABLE to repoint your original Rec on RecRefs Position.0
-
pduck,
I changed the code tolrecref.GETTABLE(Rec); lfldref:= lrecref.FIELD(FIELDNO("Vendor No.")); lfldref.SETFILTER('10-0085'); lrecref.FIND('-'); <--- added lrecref.settable(rec);
but still not working
I tried two different places:
1) OnInit: first record matches filter displayed but subsequent records ignore the filter
2) OnAfterGetRecord: can't move to another records except the first matching one
any other suggestions?0 -
Does it work when you replace SETFILTER WITH SETRANGE? Maybe it needs a full qualified FilterString like "= 'XYZ'" when using SETFILTER.0
-
I propose you anther way to do the same.
Table.OPEN(27) //Item
lfldref:= lrecref.field(fieldno("Vendor No."));
table.SETVIEW(' WHERE (' + lfldref.CAPTION + ' = CONST('10-0085'))');
IF table.FINDFIRST THEN
repeat
---
----
until (table.next=0)
Regards0 -
I just tried using SETVIEW...the filter worked as expected...but with one drawback: user can see the filter and change it!
Too bad we can't combine SETVIEW with FILTERGROUP
Any inputs?0 -
dsatria wrote:How do we put filter on Item Card form using C/AL code?
I tried this but not work:lRecRef.gettable(rec); lfldref:= lrecref.field(fieldno("Vendor No.")); lfldref.setfilter('10-0085'); lrecref.settable(rec)
My plan is to make a dynamic filter based on field/value defined on other table.
The problem might be the code on the "Item Card" form, which clears the filters on after get record
Form - OnAfterGetRecord()
SETRANGE("No.");
ItemCostMgt.CalculateAverageCost(Rec,AverageCostLCY,AverageCostACY);
EnablePlanningControls;Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0
Categories
- All Categories
- 75 General
- 75 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 250 Dynamics CRM
- 102 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions