sort in RecordRef

trulyjacky
Member Posts: 24
Hi,
Is there any way to sort in RecordRef? I know the SETCURRENTKEY in Record can sort the table. But how about RecordRef? I have to use RecordRef because I am not able to determine the table ID at design time.
Is there any way to sort in RecordRef? I know the SETCURRENTKEY in Record can sort the table. But how about RecordRef? I have to use RecordRef because I am not able to determine the table ID at design time.
0
Comments
-
Try this:
Cust.SETCURRENTKEY("Search Name"); Recref.OPEN(DATABASE::Customer); Recref.SETTABLE(Cust); MESSAGE(Recref.CURRENTKEY);
"Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."0 -
Thanx eromein. But the problem is that I can't say it must be the Customer table, at design time.
For example, during run time, the end user may choose from Customer Ledger Entry, Vendor Ledger Entry and Employee Ledger Entry, just as what they want.
So my RecordRef have to be capable refer to either of these tables and after that, sort that table with Field No.3 (also is Field Index 2), which is either the Customer No., Vendor No. or Employee No.0 -
Could you maybe think of a way to define these things in some kind of settings?
I made a tool some time ago with which you can find anything in Navision. You can setup relation, conditions, filters and even keys. But these "search rules" are predefines.
Sample:
Search from "sales line", if "type = item", for "item", field "search description" where "BOM = yes" with key "search description".
So as you can see, in my tool, the key is pre-set or pre-defined.
I think you sould do something like that. Or you could make something that looks-up the best key there is and activated it.
BTW, here is another way to set a key:recref.setview(strsubno('SORTING(%1)',keyname));
Keyname is something like: "field1,field2,field3"
Here's a little functions that I made which generates keynames:GetKeyName(recno : Integer;keyno : Integer) KeyString : Text[250] IF (recno = 0) OR (keyno = 0) THEN EXIT recref.open(recno); keyref := recref.keyindex(keyno); IF NOT keyref.ACTIVE THEN EXIT; NumOfKeyFields := keyref.FIELDCOUNT; FOR i := 1 to NumOfKeyFields DO BEGIN fieldref := keyref.FIELDINDEX(i); keystring := STRSUBSTNO('%1%2%3',keystring,separator,fieldref.NAME); separator := ','; END;
Good luck!"Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."1 -
"Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."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