BC22 - Remove Single Quotes from Filter Totals By

IrishGiriIrishGiri Member Posts: 61
edited 2024-05-22 in NAV Three Tier
Hi all,

I am trying to find a way, without much success, to remove the leading and trailing single quotes that somehow get included when passing a custom field of Type Text in the Item Journal Line, e.g LOT0000067|LOT0000069..LOT0000071 (without single quotes), to the Filter Totals By field called "Lot No. Filter" in the Get Contents Bin report below. In the Request Options form of the report the string shows up as 'LOT0000067|LOT0000069..LOT0000071' (with single quotes!)

Annoyingly, the report only works when the leading and trailing single quotes are removed manually, not very user-friendly, but I can't find where to remove them via code???

j2iy2idnacze.png



This is the code I use to populate the filters on the report request form:

[EventSubscriber(ObjectType::Page, Page::"Item Reclass. Journal", 'OnActionGetBinContentOnAfterSetFilters', '', false, false)]
local procedure "Item Reclass. Journal_OnActionGetBinContentOnAfterSetFilters"(var ItemJournalLine: Record "Item Journal Line"; var BinContent: Record "Bin
Content")
begin
BinContent.SetRange("Bin Code", ItemJournalLine."Bin Code");
BinContent.SetRange("Item No.", ItemJournalLine."Item No.");
BinContent.SetRange("Lot No. Filter", ItemJournalLine."Lot No. Filter");
end;



Any suggestions woud be gratefully appreciated! 👍

Paul.

Answers

  • lubostlubost Member Posts: 623
    Use SetFilter("Lot No. Filter", '%1', ItemJournalLine."Lot No. Filter"); instead of BinContent.SetRange("Lot No. Filter", ItemJournalLine."Lot No. Filter");
  • IrishGiriIrishGiri Member Posts: 61
    Thanks for your suggestion, but unfortunately that doesn't remove the quotes either end of the filter in the request page of the report. Same result, I'm afraid
  • lubostlubost Member Posts: 623
    Try use DELCHR(ItemJournalLine."Lot No. Filter", '<>', Apostroph), where Apostroph is defined as a TextConstant with single quote.
  • IrishGiriIrishGiri Member Posts: 61
    edited 2024-05-23
    I think you mean DELCHR(ItemJournalLine."Lot No. Filter", '=', Apostroph , right?

    Either way, this doesn't remove the single quotes in the request page. The ItemJournalLine."Lot No. Filter" is correct, with no single quotes. Then when the request page opens, the value for Lot No. Filter there continues to have single quotes. :s
  • IrishGiriIrishGiri Member Posts: 61
    Does anyone know if there is already any existing standard report in the Base Application that that takes a filter containing .. or | from a record on a page and, when the report is run from an action on that page, it has a Filter Totals By field initialized in its request page without a leading and trailing single quote???
  • vaprogvaprog Member Posts: 1,139
    Your field contains a filter. Just set it. Use
    SetFilter("Lot No. Filter", ItemJournalLine."Lot No. Filter");
    

    SetRange quotes the value so in the end it finds a record with the value specified. That is, what the function is designed to do.

    SetFilter is a bit more complicated. I have documented my findings in the following posts:

    Filtering question
    Percentage Sign handling in NAV is dangerously flaky.
Sign In or Register to comment.