get records based on different table from one filter is set

Morgan
Member Posts: 12
Dear friends,
I explain in a simple way, I have 3 tables:
-Edition (Code, Designation,...) // Primary key is Code
-Page (Code, Designation,...) // Primary key is Code
-Edition/Page Assignment (Edition Code, Page Code,...) // Primary key is Edition Code, Page Code
I set filter on "Edition/Page Assignment" in order to only have pages for one Edition.
-> EditionRec is the Record resulting of EditionRec.SETFILTER(Edition Code,'my_edition_code');
I want to open the form "List of Pages" based on Table "Page" but filtering the records in order to only get the list of pages contained in EditionRec (in a specific edition).
=> problem is : in FORM.RUNMODAL(formID,RECORD) , RECORD is based on the source table, in my case EditionRec is not based on the form source table.
I don't know if it is possible to get only some records based on table "Page" when you have a list of page code for example....
PS:For one edition, it is possible to have sereval times the same page with different Headers and sub-headers
Thanks!
I explain in a simple way, I have 3 tables:
-Edition (Code, Designation,...) // Primary key is Code
-Page (Code, Designation,...) // Primary key is Code
-Edition/Page Assignment (Edition Code, Page Code,...) // Primary key is Edition Code, Page Code
I set filter on "Edition/Page Assignment" in order to only have pages for one Edition.
-> EditionRec is the Record resulting of EditionRec.SETFILTER(Edition Code,'my_edition_code');
I want to open the form "List of Pages" based on Table "Page" but filtering the records in order to only get the list of pages contained in EditionRec (in a specific edition).
=> problem is : in FORM.RUNMODAL(formID,RECORD) , RECORD is based on the source table, in my case EditionRec is not based on the form source table.
I don't know if it is possible to get only some records based on table "Page" when you have a list of page code for example....
PS:For one edition, it is possible to have sereval times the same page with different Headers and sub-headers
Thanks!
0
Comments
-
Well, there are several ways to handle this kind of problem.
Here are some:
1.
You can create some kind of functionality that concatenates the filter you need. The code can be like this:txtFilter := ''; IF EditionRec.FIND('-') THEN REPEAT txtFilter := txtFilter + EditionRec.Code + '|' UNTIL EditionRec.NEXT = 0; //To remove the last '|' IF txtFilter <> '' THEN txtFilter := COPYSTR(txtFilter,1,STRLEN(txtFilter)-1);
This way you have your filter, which you can use like this to open your form:PageRec.SETFILTER(Code,txtFilter); FORM.RUNMODAL(FormID,PageRec);
2.
If it is not necessary to edit in the form you want to open, just create some LookUp-Flowfields in the Edition/Page-table that looks up the descriptions you want from the Edition table and the Page table. Then, you can base your list-form on the Edition/Page-table, and just use the filter on EditionRec (GETFILTER(Code)).
I hope this is clear, and this can help you ...
Regards.0 -
Great, first solution works well !!
Thanks a lot Waldo0 -
COPYFILTER would have also worked.
Record.COPYFILTER(FromField, ToRecord.ToField)
This will copy the filter from the first specified Table.Field to the second specified Table.Field.
A lot simpler.This isn't a signature, I type this at the bottom of every message0 -
I think you're wrong.
The filter is on "Edition Code" of the Edition/Page Assignment table, and he wants to filter the Page table on the code field.
But probably you just interpreted my code, which indeed you can replace by COPYFILTER. Morgan needed not exactly that code, but had to program something likewise ...
I think I should have written the following to avoid the mix-up:txtFilter := ''; IF EditionPageRec.FIND('-') THEN REPEAT txtFilter := txtFilter + EditionPageRec."Page Code" + '|' UNTIL EditionPageRec.NEXT = 0; //To remove the last '|' IF txtFilter <> '' THEN txtFilter := COPYSTR(txtFilter,1,STRLEN(txtFilter)-1);
where EditionPageRec is filtered on "Edition Code".
Regards.0 -
You're right Waldo, COPYFILTER coun't work because on Edition/Page Table, filter is appy on edition code which is not the same as the page code in Page table ....
But your solution runs well!0 -
Sorry I misunderstood the question altogether :?
Sorry for the confusion.This isn't a signature, I type this at the bottom of every message0
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