C/AL Filtering

djdave022002
Member Posts: 6
Morning, this should be simple but its evading me, hope someone can help
I am creating a report for "Item Ledger Entries", and for each record, i want to find another record in "Item Ledger Entries" based on fields from my report record.
To explain, currently I return a list of Item Ledger Entries, based on a specific customer and "document Type" "Sales Shipment" .. i then use the C/AL trigger "OnAfterGetREcord()" to take the serial number and return another record in the Item Ledger Entries, but this time with the "Document Type" of "Purchase Receipt" ..
I'm doing it this way as there is no clear relationship between the Purchase receipt of a given serialnumbered item, and the subsequent Sales Shipment of the same serial number. But i keep getting "Syntax error" when setting the second SETFILTER (i'm new to C/AL coding but that's not a brilliant error code unless i'm looking in the wrong place!)
I understand from research that SetFilter overwrites previous SetFilter statements but in that case i cant easily understand how to apply two filters ?
I have a global set for "Item Ledger entry" named ILERec ... and i have only one dataitem in my dataset, which is again "Item Ledger Entry"
I am creating a report for "Item Ledger Entries", and for each record, i want to find another record in "Item Ledger Entries" based on fields from my report record.
To explain, currently I return a list of Item Ledger Entries, based on a specific customer and "document Type" "Sales Shipment" .. i then use the C/AL trigger "OnAfterGetREcord()" to take the serial number and return another record in the Item Ledger Entries, but this time with the "Document Type" of "Purchase Receipt" ..
I'm doing it this way as there is no clear relationship between the Purchase receipt of a given serialnumbered item, and the subsequent Sales Shipment of the same serial number. But i keep getting "Syntax error" when setting the second SETFILTER (i'm new to C/AL coding but that's not a brilliant error code unless i'm looking in the wrong place!)
I understand from research that SetFilter overwrites previous SetFilter statements but in that case i cant easily understand how to apply two filters ?
I have a global set for "Item Ledger entry" named ILERec ... and i have only one dataitem in my dataset, which is again "Item Ledger Entry"
Item Ledger Entry - OnAfterGetRecord() ILERec.SETRANGE("Serial No.","Serial No.") ILERec.SETRANGE("Document Type",Rec."Document Type"::"Purchase Receipt") IF ILERec.FINDFIRST THEN MESSAGE(Text000 + ILERec."Document No.") ELSE MESSAGE(Text001 + ILERec."Document No.")
0
Best Answer
-
Your sample code is missing semicolons at the end of lines, so that's probably what's causing your "Syntax error".
And in your second filter, you might wanna use ILERec instead of Rec when selecting Document Type option, i.e.ILERec.SETRANGE("Document Type",ILERec."Document Type"::"Purchase Receipt");
5
Answers
-
Your sample code is missing semicolons at the end of lines, so that's probably what's causing your "Syntax error".
And in your second filter, you might wanna use ILERec instead of Rec when selecting Document Type option, i.e.ILERec.SETRANGE("Document Type",ILERec."Document Type"::"Purchase Receipt");
5 -
Wow, i'm slightly embarassed by that omission! but thank you, works perfectly !0
-
djdave022002 wrote: »I understand from research that SetFilter overwrites previous SetFilter statements but in that case i cant easily understand how to apply two filters ?
Setfilter statements will only overwrite eachother if it's on the same key, i.e:SETFILTER(Document type..xyz); SETFILTER(Serial no....xyz);
Will set both filters and not overwrite eachother, for more info see the microsoft documentation on setfilter.
1
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