How to select multiple records to filter a report

johnnyp
Member Posts: 14
Hello everyone.
I'm creating a simple report (Dynamics NAV 2017), that reads data from two similar tables, joins all into one temporary and prints it into excel. All nice and simple. I've set the RequestedFilterField for both tables to "Document No.". Now as filters go, I can select single record, put a pipe (|) and select the next record ... works fine, but is extremely time consuming. My idea is, that when you drill down (or lookup, idk) into "Document No.", you could select multiple records (either with Shift or Ctrl) and when pressing OK it would fill my "Document No." filter with selected document numbers. I'm not sure if this can be achieved by standard funcionalities.
Any help is greatly appreciated.
Best regards, John
I'm creating a simple report (Dynamics NAV 2017), that reads data from two similar tables, joins all into one temporary and prints it into excel. All nice and simple. I've set the RequestedFilterField for both tables to "Document No.". Now as filters go, I can select single record, put a pipe (|) and select the next record ... works fine, but is extremely time consuming. My idea is, that when you drill down (or lookup, idk) into "Document No.", you could select multiple records (either with Shift or Ctrl) and when pressing OK it would fill my "Document No." filter with selected document numbers. I'm not sure if this can be achieved by standard funcionalities.
Any help is greatly appreciated.
Best regards, John
0
Best Answers
-
Create field in your request page, add the following:
<Control1100494004> - OnLookup(VAR Text : Text[1024];) : Boolean
ThePage.SETTABLEVIEW(TheTable);
ThePage.EDITABLE(FALSE);
ThePage.LOOKUPMODE(TRUE);
IF ThePage.RUNMODAL=ACTION::LookupOK THEN BEGIN
ThePage.GetRecords(TheTable);
TheTable.MARKEDONLY(TRUE);
IF TheTable.FINDSET THEN BEGIN
CLEAR(FilterString);
REPEAT
IF FilterString = '' THEN
FilterString := TheTable."Transaction No."
ELSE
FilterString := (FilterString + '|' + TheTable."Transaction No.");
UNTIL TheTable.NEXT <= 0;
END;
END;
In ThePage create function:
GetRecords(VAR TheTableV : Record "The Table")
TheTableV.COPY(Rec);
TheTableV.MARKEDONLY(TRUE);
IF TheTableV.COUNT = 0 THEN BEGIN
TheTableV.COPY(Rec);
TheTableV.MARK(TRUE);
END;
TheTableV.MARKEDONLY(FALSE);
6 -
I'm sorry, this was written for classic client where you could mark the records using CTRL+F1.
Try adding SETSELECTIONFILTER, this marks the records too. But in a different way.
GetRecords(VAR TheTableV : Record "The Table")
CurrPage.SETSELECTIONFILTER(Rec);
TheTableV.COPY(Rec);
TheTableV.MARKEDONLY(TRUE);
IF TheTableV.COUNT = 0 THEN BEGIN
TheTableV.COPY(Rec);
TheTableV.MARK(TRUE);
END;
TheTableV.MARKEDONLY(FALSE);
Check this out too:
https://docs.microsoft.com/en-us/dynamics-nav/setselectionfilter-function6
Answers
-
[Topic moved from 'NAV Tips & Tricks' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Not standard.0
-
Any suggestion how to achieve my goal if, as you say, this cannot be done by standard functionalities?0
-
Create field in your request page, add the following:
<Control1100494004> - OnLookup(VAR Text : Text[1024];) : Boolean
ThePage.SETTABLEVIEW(TheTable);
ThePage.EDITABLE(FALSE);
ThePage.LOOKUPMODE(TRUE);
IF ThePage.RUNMODAL=ACTION::LookupOK THEN BEGIN
ThePage.GetRecords(TheTable);
TheTable.MARKEDONLY(TRUE);
IF TheTable.FINDSET THEN BEGIN
CLEAR(FilterString);
REPEAT
IF FilterString = '' THEN
FilterString := TheTable."Transaction No."
ELSE
FilterString := (FilterString + '|' + TheTable."Transaction No.");
UNTIL TheTable.NEXT <= 0;
END;
END;
In ThePage create function:
GetRecords(VAR TheTableV : Record "The Table")
TheTableV.COPY(Rec);
TheTableV.MARKEDONLY(TRUE);
IF TheTableV.COUNT = 0 THEN BEGIN
TheTableV.COPY(Rec);
TheTableV.MARK(TRUE);
END;
TheTableV.MARKEDONLY(FALSE);
6 -
TallyHo, thank you for your suggestion. I implemented it, and it works, to a degree. Lookup works great, I can select my records, however the function that should return a set of records, only returns 1 record. Any ideas why?0
-
I'm sorry, this was written for classic client where you could mark the records using CTRL+F1.
Try adding SETSELECTIONFILTER, this marks the records too. But in a different way.
GetRecords(VAR TheTableV : Record "The Table")
CurrPage.SETSELECTIONFILTER(Rec);
TheTableV.COPY(Rec);
TheTableV.MARKEDONLY(TRUE);
IF TheTableV.COUNT = 0 THEN BEGIN
TheTableV.COPY(Rec);
TheTableV.MARK(TRUE);
END;
TheTableV.MARKEDONLY(FALSE);
Check this out too:
https://docs.microsoft.com/en-us/dynamics-nav/setselectionfilter-function6 -
TallyHo, you're a lifesaver!! It worked like a charm. Thank you for your help.0
-
You're welcome!0
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