Filtering Unique records during Runtime

HI I want to get all the unique records from a table during runtime. What i mean is When a table has dupicate records, Using SETRANGE , i want to have the uniqe recordsm based on a field. bye

If I understand the question correctly, you are going to need to create a field that will be an identifier field, or in other words, be unique, based on a certain key. If you are looking at a Ledger table, you of course get the “Record No.” field that distinguishes all your records. Perhaps try something like that? I would set it up so that you run a check using the key you wish to keep unique records on during the OnInsert trigger of the table. When you see an existing record based on the key, you will insert the new record with a “Record No.” integer field that will increment by 1. This will require that you add a “Record No.” field to the table, of course. Regards! Kristopher Webb Kelar Corporation, Canada

From what I’ve understand the functionality should be identical to “SELECT DISTINCT” SQL statement. As to my knowledge there is no such function in Navision. It could be done by adding a boolean field “Unique” which can be filled with TRUE/FALSE accordingly to the values of the field you want to get unique records for. Then a simple filter on this filed will give you the unique records. brgds.

Hi! I use folowing metod: 1. Create new key if nessesery, which includes all fields on which you determine if record is unique or not. 2. use this key in SETCURRENTKEY 3. create new var for each field in key 4. pseudo code varField1 := ‘’; // or 0 or 0D, depends od datatype varField2 := ‘’; varField3 := ‘’; recYourTable.RESET; recYourTable.SETCURRENTKEY(Field1,Field2,Field3) recYourTable.SETRANGE,… set range of filter that you need boolDone := NOT recYourTable.FIND(’-’); WHILE NOT boolDone DO BEGIN IF recYourTable.Field1 <> varField1 OR recYourTable.Field2 <> varField2 OR recYourTable.Field3 <> varField3 THEN BEGIN varField1 := recYourTable.Field1; varField2 := recYourTable.Field2; varField3 := recYourTable.Field3; recYourTable.MARK(TRUE); END ELSE BEGIN recYourTable.MARK(FALSE); END; boolDone := recYourTable.NEXT = 0; END; recYourTable.MARKEDONLY(TRUE); 5. Now you should have only uniqe records in recYourTable regards Bostjan