C/AL Filtering

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"
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.")

Best Answer

Answers

  • djdave022002djdave022002 Member Posts: 6
    Wow, i'm slightly embarassed by that omission! but thank you, works perfectly !
  • PhoguePhogue Member Posts: 76
    edited 2019-08-19
    I understand from research that SetFilter overwrites previous SetFilter statements but in that case i cant easily understand how to apply two filters ?
    @djdave022002

    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.
Sign In or Register to comment.