Linking Imported Contacts to Accounts - which method?

S

Steve

I know BCM 2007 does not support contact->account linking when using flat
files, so I gather there are 2 workarounds:

1) Create a .bcm XML formatted input file. I see this file uses GUID
linking - if I create one, how should I assign the GUID? Can I just make up
a unique 32 char hex id, or do I need a specific algorithm?

2) Import contacts and accounts separately then link them in the db via SQL.
Can anyone supply sample SQL for this, or point me to a reference?

Thanks!
 
F

farouk drif

hello,

I was in same situation a few month ago, i had to import contacts and
accounts from an existing Access database in my company, it was not very
difficult to discover how it is linking but i had to test to be sure that
modifying the SQL Database directly won't affect BCM. So i did it using SQL,
and until now there is no problem so i think it is a good method even if i
did not explore entirely what happened when the link is created by BCM.

I wanted to write a post or a blog but i was not sure that it will help
somebody, i was wrong :)

So i will be happy to help you,
 
N

Nancy R

Hi Farouk,

How did you do it in SQL? I have been looking at it with Access and SQL
Server Management Studio Express for a little while now.

I have figured out which fields I need to update but I am still having
trouble figuring out where to pull it from. I have about 18000 contacts and
1700 accounts I need to get linked together, no way will I do them manually.

I have the linking information in a separate excel file which I have managed
to import into a SQL table as someone else suggested this would be the
easiest way to do the update.

My SQL knowledge is very limited so I'm not sure where go from here.

Any help you could give me would be greatly appreciated.

Thanks in advance,
Nancy
 
F

farouk drif

hello,

First, have you already import your data in BCM ? if it's done, i hope you
stored the linking information in a user field or somewhere else. Which step
are you ?

The method is to use a temporary key, stored in a non-BCM table, or in the
BCM table with the "user fields" , this key will be used to operate the link
between contact and account to link them by updating some fields in the
principal BCM table, BCM will believe that he did the link.

Could you answer my questions and i'll be able to guide you.
 
N

Nancy R

Hi Farouk,

Thanks for your reply.

The accounts and contacts are in the BCM but we did not store the linking
information in a user field, I have this in my original excel spreadsheet.

If necessary I can start fresh to add this information however it takes
several hours for the import to complete so I would need to leave it running
at the end of the day today.

Alternatively, I can get the contents of the excel file into a separate SQL
table, that is not a problem. Should it be in the BCM db or in a different
one?

Thanks again,
Nancy
 
F

farouk drif

sorry to answer only now but the newsgroup did not notify me of replies,
just to say that i'm writing a procedure to explain how to do it step by
step, because it seems that it could help a lot of people. i will release it
in a few days.
 
M

Mark W

Hi Nancy

I had to do the same thing. One of our salesmen loaded accounts and contacts
in on 22/8/2008 so I used my rudimentary SQL skills to associate the right
contacts with the right accounts, but only for the records loaded on the
22/8/2008.
This was how I did it using 3 Views to compensate for my lack of SQL skills
- you can adjust to suit. You will need admin access to the SQLserver
database.

1) Set your BCM to work Offline, and make sure no-one else is using BCM.
2) Open SQL Management Studio and connect to the BCM database server -
usually this is in the SQLServer instance called MSSMLBIZ then backup the
MSSmallBusiness database for safekeeping.
3) Expand the MSSmallBusiness database and right click on the Views and
Select New View. Close the Add Tables dialogue that may pop up and find the
SQL panel (it usually contains the words SELECT FROM)
4) Paste in the following statement :
SELECT
acc.ModifiedOn, acc.ModifiedBy, acc.EntryGUID AS AccGUID,
cnt.FullName AS AccName, acc.Type, acc.PrimaryContactGUID
FROM
dbo.ContactMainTable AS acc INNER JOIN
dbo.ContactNamesTable AS cnt ON acc.ContactServiceID = cnt.ContactServiceID
WHERE
(acc.ModifiedOn > '22 August 2008') AND (acc.ModifiedOn < '23 August 2008')
AND (acc.Type = 2)

5) Change dates to suit, click on the red ! to run it, just to check it
works, then save the view, give it the name NHAccounts
6) Add another new view like in step 3, but paste in the following statement:
SELECT Type, EntryGUID AS ContactGUID, CompanyName, ParentType,
ParentEntryID, ParentContactServiceID
FROM dbo.ContactMainTable AS con
WHERE (Type = 1) AND (CompanyName IS NOT NULL) AND (ModifiedOn > '22
August 2008') AND (ModifiedOn < '23 August 2008') AND (ParentContactServiceID
IS NULL)

7) Change dates to suit, then run it like the other to test then save this
view with the name NHContacts

8) Add another new view like in step 3, but paste in the following statement:
SELECT
dbo.NHAccounts.ModifiedOn, dbo.NHAccounts.ModifiedBy,
dbo.NHAccounts.AccGUID, dbo.NHAccounts.AccName, dbo.NHContacts.Type AS
ContactType, dbo.NHContacts.ContactGUID, dbo.NHContacts.CompanyName,
dbo.NHContacts.ParentType, dbo.NHContacts.ParentEntryID,
dbo.NHAccounts.AccID, dbo.NHAccounts.Type, dbo.NHAccounts.PrimaryContactGUID,
dbo.NHContacts.ParentContactServiceID
FROM
dbo.NHAccounts INNER JOIN
dbo.NHContacts ON dbo.NHAccounts.AccName = dbo.NHContacts.CompanyName

9) Run it like the other to test then save this view with the name NHUpdate
You can close the design panels after saving the views. Now you are ready to
run the update command.
10) Right click on MSSmallBusiness and select New Query
11) To check how many records will be changed before actually doing it paste
in the following statement and execute.
Select * from NHUpdate;

12) If you are happy with the selection then it's time to run the
command..Paste in the following update statement and Execute the query

update NHAccUpdate set Parenttype=2, parententryid=AccGUID,
ParentContactServiceID=AccId where parenttype is null;

12) You should get a message telling you how many rows were affected.

That's it :)

Set your BCM online, let it update its database and check your accounts and
contacts. They should be linked up now.

There are fancier ways to do this with one monster UPDATE statement but this
way you can use the views to check the accounts and contacts before you run
things and tweak the dates to constrain the update to specific records. You
can also the views for checking in future.

I used a variation to assign primarycontacts to each account, but actually
the account manager should decide that sort of thing!!
 
M

Mark W

A correction to my previous!

Item 12) should be

update NHUpdate set Parenttype=2, parententryid=AccGUID,
ParentContactServiceID=AccId where parenttype is null;


This method assumes that every contact has a CompanyName entry which matches
an Account Full Name. this is how it cross-references contacts with accounts.
 
N

Nancy R

Hi Mark,

This is fabulous, it looks like it will do exactly what I need.

I'll play with it today and let you know how I make out.

Thank you so much!!!
 
N

Nancy R

Hi Mark,

I went through what you sent and it is great but I have a couple of
questions that I am hoping you can help with:

1 - My account names do not always match the company name of the contact
(some of them have several branch offices with different names) so I need to
pull the actual account name. This information is currently stored in a
custom BCM contact field, is there any way to update the parent account info
from a custom field? I looked through almost all of the SQL tables but I
can't find these custom fields or the data entered there.
2 - In NHUpdate, it is pulling NHAccounts.AccGUID and NHAccounts.AccID. I
get an error for AccID. I know this is because it doesn't exist as a field
in NHAccounts but I couldn't figure out which field it should be. Am I
missing something besides my sanity?

I'm sorry for all of the questions, You may only have "rudimentary" sql
knowledge but it's far stronger than mine!

Again, I appreciate you taking the time to help out with this.

Nancy
 
M

Mark W

Hi Nancy.

Yes, I am a plonker.

The NHAccounts view should contain the following - notice the AS AccID bit
which I missed out previously. To change, right-click on the NHAccounts view
and select Design, then paste the stuff below into the SQL pane, replacing
the previous statement, then save it.

SELECT
acc.ModifiedOn, acc.ModifiedBy, acc.EntryGUID AS AccGUID,
cnt.FullName AS AccName, acc.ContactServiceID AS AccID,
acc.Type, acc.PrimaryContactGUID
FROM
dbo.ContactMainTable AS acc INNER JOIN
dbo.ContactNamesTable AS cnt ON acc.ContactServiceID = cnt.ContactServiceID
WHERE (acc.ModifiedOn > '22 August 2008') AND (acc.ModifiedOn < '23
August 2008') AND (acc.Type = 2)


As for the custom contact field, these are tricky to identify because there
are different types and they are stored in various tables, basically the name
of the user field is stored in the UserFieldDefinitions table, this
cross-references somehow to the ContactAdditionalPropertyBag, and this
cross-references somehow to the Contact via the ContactID, but I have not
been able to figure out how it works.

You can try a fuzzy matching to associate the comapny name with account name
by using the LIKE comparison operator, so instead of the following bit in
NHUpdate view

FROM
dbo.NHAccounts INNER JOIN
dbo.NHContacts ON dbo.NHAccounts.AccName = dbo.NHContacts.CompanyName

you could try

FROM
dbo.NHAccounts INNER JOIN
dbo.NHContacts ON dbo.NHAccounts.AccName LIKE '%' +
dbo.NHContacts.CompanyName + '%'

which means match any account which contains the account name somwhere in
the copmany name. - I may give you some more matches, but watch out for wrong
matches!
 
N

Nancy R

Thank you very very much for all of your help, this seems to be exactly what
I needed!

The fuzzy match clears up most of what the exact match doesn't. It looks
like I only have to link up about 2000 of my original 18000, and if I setup
my filters in Outlook I should be able to do this reasonably quickly.

Thanks again,
Nancy
 
A

azur

Hello everybody

...Very Helpfull !

I test all that things but i have a strange problem.

In the contact view, the contact are linked to the account.

In the account view, there are not the contact represented.

Can you help with that ?


Sorry for my bad english
 
L

Luther

Hello everybody

..Very Helpfull !

I test all that things but i have a strange problem.

In the contact view, the contact are linked to the account.

In the account view, there are not the contact represented.

Can you help with that ?

Sorry for my bad english














- Show quoted text -

Probably the Business Contacts records have a column with the parent,
but the Accounts records don't have a column with their children. It
makes sense, since Business Contacts can only have one parent, but
Accounts can parent multiple Business Contacts.
 
A

Azur

Probably the Business Contacts records have a column with the parent,
but the Accounts records don't have a column with their children. It
makes sense, since Business Contacts can only have one parent, but
Accounts can parent multiple Business Contacts.





Hello Luther,

Contacts table and Account tables are probably linked.
I think that the account record have a column with their Children its the
index.

The database's fonctionnalities are able to resolve that problem.

My english is to bad to explain what i think.

May be i misunderstand ?

thanks for you reply.

-azur-
 
L

Luther

Hello Luther,

Contacts table and Account tables are probably linked.
I think that the account record have a column with their Children its the
index.

The database's  fonctionnalities are able to resolve that problem.

My english is to bad to explain what i think.

May be i misunderstand ?

thanks for you reply.

-azur-

I recall the Business Contacts, Accounts, and Opportunties are all
stored in the same table, but can be accessed seperately through their
respective Views. I believe that table has a parents column, but not a
children's column.
 
A

Azur

Hello Luther

Thanks for your reply.

I have not the time to solve thats problem.

I 'll go back later when i'll put the people back my door away...


-azur-



"Luther" <[email protected]> a écrit dans le message de (e-mail address removed)...
Hello everybody

..Very Helpfull !

I test all that things but i have a strange problem.

In the contact view, the contact are linked to the account.

In the account view, there are not the contact represented.

Can you help with that ?

Sorry for my bad english














- Show quoted text -

Probably the Business Contacts records have a column with the parent,
but the Accounts records don't have a column with their children. It
makes sense, since Business Contacts can only have one parent, but
Accounts can parent multiple Business Contacts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top