Community
Showing results for 
Search instead for 
Do you mean 
Reply

Really interesting contact update problem - VB.NET

New Member
Posts: 6
Country: USA

Really interesting contact update problem - VB.NET

I have identified a really interesting problem I am trying to fill in missing contact information for one contact, using data from another contact. I have a search function that finds all of the comparable contacts, and another function that selects the best fit out of whatever contacts are comparable. For a particular contact, the 'best fit' comparable is contact #1479 in the contactlist Here's where it gets interesting: a) If I disable the search function so that it doesn't even look at the contactlist, but simply return 1479 as the 'best fit' contact, the contact that needs more data will update without any problems (State=Unchanged after update) b) if I run the search function and force an answer of 1479 as the best fit, the contact cannot be updated. Thus, merely the act of looping through the contactlist appears to cause problems in updating a contact that I want to update! Thoughts? Nick ======================================== Here's the relevant code snippet: ptrs = Activator_ContactDataMerge_comparables(contact, contactlist) 'look for records that are comparable to the current one a = Activator_ContactDataMerge_bestfit(contact, contactlist, ptrs) 'select the best fit t = "Contact.Address 1" contact.ContactFields.Item(t) = contact(a).ContactFields.Item(t) contact.Update() MsgBox(contact.State.ToString) AND HERE ARE THE TWO FUNCTIONS: Function Activator_ContactDataMerge_bestfit(ByVal contact As Act.Framework.Contacts.Contact, ByVal conlist As Act.Framework.Contacts.ContactList, ByRef ptrs() As Integer) As Integer Dim co() As String = (CORE_FIELDS & ",Phone").Split(","), s As String Dim vals(), a, b, hival, hivalptr As Integer If ptrs.Length = 0 Then hivalptr = -1 ElseIf ptrs.Length = 1 Then hivalptr = ptrs(0) Else ReDim vals(ptrs.Length - 1) hival = -1 hivalptr = -1 For a = 0 To ptrs.Length - 1 For b = 0 To co.Length - 1 s = conlist(ptrs(a)).ContactFields.Item("Contact." & co(b)) If s <> "" Then vals(a) += 1 End If Next If vals(a) > hival Then hival = vals(a) hivalptr = ptrs(a) End If Next End If Return hivalptr End Function Function Activator_ContactDataMerge_comparables(ByVal contact As Act.Framework.Contacts.Contact, ByVal conlist As Act.Framework.Contacts.ContactList) As Integer() Dim ints() As Integer = {1479} 'Return ints 'Exit Function Dim arrl As New ArrayList Dim p As Integer = 0 Dim s As String s = contact.ContactFields.Item("Contact.E-mail") If s = Nothing Then s = "" If s <> "" Then Do While p < conlist.Count p = Activator_FindContactPointer(conlist, "E-mail", s, p, True) If p = conlist.Count Then Exit Do If conlist(p).ID.ToString <> contact.ID.ToString Then arrl.Add(p) End If p += 1 Loop End If p = 0 s = contact.ContactFields.Item("Contact.Phone") If s = Nothing Then s = "" If s <> "" Then Do While p < conlist.Count p = Activator_FindContactPointer(conlist, "Phone", s, p, True) If p = conlist.Count Then Exit Do If arrl.IndexOf(p) < 0 Then If conlist(p).ID.ToString <> contact.ID.ToString Then arrl.Add(p) End If End If p += 1 Loop End If Dim arr As Array If arrl.Count = 0 Then arr = Nothing Else arr = Array.CreateInstance(GetType(Integer), arrl.Count) For p = 0 To arr.Length - 1 arr(p) = arrl(p) Next End If arrl = Nothing Return ints End Function
Nickel Contributor
Posts: 175
Country: USA

Re: Really interesting contact update problem - VB.NET

Could you please re-post the code utilizing the Insert Code feature when posting? It is currently a pain to read, and since it's not C#, it doesn't have an end-line character to help break it apart. I honestly gave up reading once I hit the code.

 

Now, just a thought, picking parts of what I can see. I see "{1479}" hard-coded in there and you mentioned forcing the function to return that. Could it be that when you force that, you are returning the Integer 1479, and when you aren't forcing it, you are returning the contact itself or doing something else to set the contact?