Hi,
In the table 5085 "Contact Duplicate" I try to get the Contact which has:
1. a specified Contact No
2. the highest No. of Matching Strings
Example:
Table Contact Duplicate
I want to get the Contact "44444444" which has the highest No. of Matching Strings (with the value "2" in this example).
First, I have to set the "Contact No." - filter on the ""Contact Duplicate" record:
Duplicates.SETFILTER(Duplicates."Contact No.", '44444444');
And then, how can I now set an additional filter to get the appropriate record with the highest "No. of Matching Strings" ? #-o
Answers
Add a new key to the Contact Duplicate table:
No. of Matching Strings
Then,
Of course, you need to bear in mind that there could be more than one record with the same number of matching strings, so you will need to decide how you want to handle that.
www.NextEqualZero.com
A technical eye on Dynamics NAV
first: Make an new key in the table with No. of Matching Strings and than use setcurrentkey("No. of Matching Strings")
second: You create in your function an loop and go throw the records in filter and select there the rec with the highest No. of Matching Strings
But it's possible, that you have more than one record with the same No. of Matching Strings,
Regards
I've tried it with the following code...
... and received the following error-message: Message :-k
Freelance Developer
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
You need to add the No. of Matching Strings key to the Contact Duplicate table.
www.NextEqualZero.com
A technical eye on Dynamics NAV
In this case, I can't use this solution (can't change the table) ....
Freelance Developer
You have a developers license, no??
www.NextEqualZero.com
A technical eye on Dynamics NAV
Freelance Developer
Ok, then you will need to go for a solution using a loop.
Something along these lines (code untested):
The first section determines what the maximum No. of Matching Strings value is.
The second section sets a range on this value (remember there could be more than one record).
Hope this helps
www.NextEqualZero.com
A technical eye on Dynamics NAV
After the loop, you've got your record in the temp variable.
This way, you avoid to send a query with a filtering on a field you don't have an index on... . And it's less traffic.
Just my two cents... too bad you're not allowed to create a key on the field. ](*,)
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Nice but.... this will only ever return 1 record.
There could be >1 record with the same No. of matching Strings
This is why you need to find out what the maximum number of matching strings is before you do anything else.
@ Navvy - Adding a key to the table is the lowest impact way to go though.
www.NextEqualZero.com
A technical eye on Dynamics NAV
Furthermore, filling a temp table in background is also a way to go. If you filter then on the "No of Matching Strings", it will be done on the client, not on the server... .
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
If he only want the first or last then this method is ok.
The fact remains, there is still the possibility of more than one record with the same No. of Matching Strings. This being the case, without using the additional key on the table, you have to find the maximum value somehow before you can do anything else.
I think a little more info on the exact requirements may be needed
[/i]
www.NextEqualZero.com
A technical eye on Dynamics NAV
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
I need only 1 record, so this solution will be perfect:
I'm developing an external add-on for NAV (screenshot.jpg). If there are more than one record (= possible contact duplicates), the user has to go into NAV and find the correct contact.
If the user doesn't go to NAV and search the correct contact manually, or this process is automated, NAV should take the contact with the highest "No. of Matching Strings".
I hope, this information helps you to understand my situation 8)
Freelance Developer
Can you pust [Solved] in the Subject?
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog