Skip to main content

Notifications

Announcements

No record found.

Concatenation of strings to use as filters in Dynamics NAV Reporting

I have been trying to get all the Item no. in the RFQ Lines (Request For Quotes Lines) as in one string concatenating all with a pipeline(‘|’).

Let me just jump into the code how did I perform this filtration.


rfqHeader.RESET;
rfqHeader.SETRANGE(rfqHeader."No.", "No.");
rfqHeader.FINDFIRST;

rfqLine.RESET;
rfqLine.SETRANGE(rfqLine."Document No.",
                  rfqHeader."No.");
IF rfqLine.FINDSET THEN
BEGIN
  REPEAT
    IF Filter = '' THEN
      Filter := rfqLine."Item No."
    ELSE
      Filter += '|' + rfqLine."Item No.";
  UNTIL rfqLine.NEXT = 0
END;

PurchInvHeader.SETRANGE(PurchInvHeader."Buy-from Vendor No.",
                          rfqHeader."Vendor No.");
PurchInvHeader.FINDFIRST;

PurchInvLine.SETFILTER(PurchInvLine."No.", Filter);
PurchInvLine.FINDSET;

CLEAR(ItemVendorReport);

ItemVendorReport.SETTABLEVIEW(PurchInvLine);
ItemVendorReport.RUN;

Variable “Filter” will concatenate all Items within the filter. Check out the screenshot.

Concatenation of strings to use as filters in Dynamics NAV Reporting

This concept is inspired by Codeunit 41, TextManagement.

In the Codeunit, please refer to the AddToFilter() method which concatenate the strings.



This was originally posted here.

Comments

*This post is locked for comments