Record Variable query

NR
Member Posts: 78
I have two recordsets filtered on different fields of an identical table.
Is it possible to have it copied to a third recordset with record source of that same table.
For eg. I have 2 Record Variable of Item table
ItemRec1 - Which is filtered on No. 1000
ItemRec2 - which is filtered on No. 1100
Now, what is the appropriate way to copy it to a third Record Variable ItemRec3
Is it possible to have it copied to a third recordset with record source of that same table.
For eg. I have 2 Record Variable of Item table
ItemRec1 - Which is filtered on No. 1000
ItemRec2 - which is filtered on No. 1100
Now, what is the appropriate way to copy it to a third Record Variable ItemRec3
0
Comments
-
Hi NR,
as I understand your problem, you need a record variable that includes both,
No. 1000 and No. 1100 is that correct ? :-k :-k
In order to achieve that, you do not need 3 instances of the same record variable, in fact, 1 record variable with an appropriate filter will do the same:
So, your global variable is:
ItemRec1 - Type is Record, Subtype is the Table you need
If you want that record variable to represent all Records in it where No. = 1000 and No. = 1100 you can do so by using:
ItemRec1.SETFILTER("No.", '%1 | %2', '1000', '1100');
Parameters:
"No." = the table field the filter is applied to
'%1 | %2' = the filter string, %1 and %2 are replaced by the parameters following, | is the logical OR
'1000' = replaces %1 on executing
'1100' = replaces %2 on executing
have a look at the C/SIDE reference in NAV, it shows the appropriate use of SETFILTER and its possibilities with |, &, .. etc.
Also, remember, when using the record variable later to retrieve its records 1 by 1 using FIND instead of GET, as FIND respects the setting of filters, which GET doesn't.
cheers,
manu
8)... I am not a programmer, I just write code.0 -
thankx manu...... for the solution0
-
However, there might be some limitations on how long a filter can be (I am not sure, but I guess)
Couldn't you just describe the business problem instead?0 -
In this case, the problem is simple, because the field you are filtering on is the primary key of the table.
But if the records were filtering on different fields that weren't primary keys, and you wanted to "merge" the results, you would have to do things differenlty.
for instance you want all records where the gen. prod posting group = rawmat OR the inventory posting group = domestic
in this case, you have to declare to records variables, and set the filter on each. Then declare a third temp variable. You loop through both sets, and try to insert all of them into temp. For instanceTempItem.deleteall ; Item1.setrange("gen. prod posting group", rawmat) ; if Item1.find('-') then repeat TempItem.Transferfields( Item1 ) ; TempItem.Insert ; until Item.next = 0 Item1.reset ; Item1.setrange("inventory posting group", domestic) ; if Item1. find('-') then repeat TempItem.transferfields (Item1) ; if TempItem.Insert then ; until Item1.next = 0
This always you set "OR" filters between fields -- instead of cumulative filters the way standard navision does.0 -
There is a limit on how long a filter can be. If I remember correctly its 250 chars.... somewhere near there anyway :-k0
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