CRM Parent Account to Outlook Company Name sync

esandstrandesandstrand Member Posts: 2
edited 2007-08-28 in Dynamics CRM
Hi everyone,

This is my first post here, so hopefully it'll be appropriate and useful.

One of the things I quickly noticed with Dynamics CRM, was that when I used the Outlook client the Parent Account field did not sync with Company Name.

I looked around a bit on the web and found a macro script that unfortunately caused an error. After much digging and trial (I am not a programmer), I understood how that the "type mismatch" error was caused.

A few mods to the script which I found here:

http://www.workopia.com/howto/DisplayPa ... ctForm.htm.


Resulted in this final one:

Sub SyncCRMCompanyName()
Dim objApp As Application
Dim objNS As NameSpace
Dim objContacts As MAPIFolder
Dim colItems As Items
Dim objContact As ContactItem
Dim strParentAcct As String
Dim i As Integer

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objContacts = objNS.GetDefaultFolder(olFolderContacts)
i = 0

Set colItems = objContacts.Items
For Each objContact In colItems
strParentAcct = ""
If objContact.CompanyName = "" Then
If objContact.UserProperties.Count > 0 Then
strParentAcct = objContact.UserProperties.Item("Parent Account")
If strParentAcct <> "" Or objContact.CompanyName <> strParentAcct Then
Rem Answer = MsgBox(strParentAcct, vbOKCancel)
objContact.CompanyName = strParentAcct
objContact.Save
i = i + 1
End If
End If
End If

Next
MsgBox ("All done: " & i & " records updated")
End Sub


Runs like a charm and puts Parent Account into Company Name!

Hope it works for you!

Thx,

-e
Check out Relationship Charts for Microsoft CRM!
http://salescentric.com/products/relati ... harts.html
Sign In or Register to comment.