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.
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.
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."
Comments
If it was hard to write, it should be hard to understand."
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.
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:
Keyname is something like: "field1,field2,field3"
Here's a little functions that I made which generates keynames:
Good luck!
If it was hard to write, it should be hard to understand."
did you take a look @ http://www.mibuso.com/dlinfo.asp?FileID=276 ?
If it was hard to write, it should be hard to understand."