web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Set filter in report using Text global variable

(0) ShareShare
ReportReport
Posted on by 729

Dear Experts,

I want to set filter on the report's dataitem using a text variable. I understand that this can be done using ReqFilterFields but the system design is as such that the records we want to select do not exist in the standard LookupPageID.

DataItem is Fixed Asset.

LookupPageID on Fixed Asset table is Fixed Asset List.

I have a field "Equipment Asset" in fixed asset table and SourceTableView in Fixed Asset List is 'WHERE(Equipment Asset=CONST(No))'.

There is another list page named Equipment FA and SourceTableView in this list page is 'WHERE(Equipment Asset=CONST(Yes))'.

Now, in my report I have a variable FANoFilter added in Request page. In the OnLookup Trigger of this variable, I have written the code as shown below,

CLEAR(EquipmentFAList);
FixedAsset.RESET;
FixedAsset.SETRANGE("Equipment Asset",TRUE);
EquipmentFAList.LOOKUPMODE(TRUE);
EquipmentFAList.SETTABLEVIEW(FixedAsset);
IF EquipmentFAList.RUNMODAL = ACTION::LookupOK THEN BEGIN
EquipmentFAList.GETRECORD(FixedAsset);
FANoFilter := FixedAsset."No.";
END;

The code shown below is on Fixed Asset - OnPreDataItem() in the report,

IF FANoFilter <> '' THEN
"Fixed Asset".SETFILTER("Fixed Asset"."No.",'%1',FANoFilter);

If I select FA0001 in FANoFilter and execute the report, the report works fine!

If I apply filter like FA0001..FA0010 or FA0001|FA0002 in this text variable (FANoFilter), the report is not considering this as a range or two FA nos., but it is taking these filters as one FA no. and the report doesn't execute.

Please guide how may I achieve the desired solution? Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    Replace your SETFILTER code like this (Use STRSUBSTNO)

    "Fixed Asset".SETFILTER("Fixed Asset"."No.",STRSUBSTNO('%1',FANoFilter));



  • Suggested answer
    Rajasekhar@MS Profile Picture
    5,569 on at

    Hi

    to apply the filters like this you need to use RecRef and FieldRef, you can observe this on Bugdet Page, see how the GLAccFilter is applied in the function MATRIX_GenerateColumnCaptions.

  • IshwarSharma Profile Picture
    729 on at

    Thank you Suresh. Your suggestion solved my problem! :)

    Thanks Rajasekhar for you reply!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans