Community
Showing results for 
Search instead for 
Do you mean 
Reply

Add Contact to Company via code

New Member
Posts: 16
Country: USA

Add Contact to Company via code

I am looking for a .Net method to add a Contact to a Company.  I have my Company object, and I have my Contact object, but I cant seem to figure out how to add the contact to the company. 

You would think there were be a method like, MyCompany.LinkContact(MyContact).  Much like the  MyContact.SetCompanyLink(MyCompany)

Does anyone know how to do it?   

 

Thanks,

b

Copper Super Contributor
Posts: 112
Country: Australia

Re: Add Contact to Company via code

you have answered your own question.. you have both a company object and a contact object

and you asked 'how to add a contact to the company'

 

MyContact.SetCompanyLink(MyCompany)

 

all you have to do is MyContact.Update() to save the link

New Member
Posts: 16
Country: USA

Re: Add Contact to Company via code

That doesn't work, or should I say it doesn't do what I want it to do.

Instead of keeping the contact at it's already assigned company, it links the company to the contact..

I want to add the contact to the company as contact not a linked contact.

 

New Member
Posts: 16
Country: USA

Re: Add Contact to Company via code

never mind. I just saw the over loaded method
MyContact.SetCompanyLink(MyCompany,false)
which does exactly what you said it would do.

Thanks.
New Member
Posts: 16
Country: USA

Re: Add Contact to Company via code

Nevermind again. It still doesn't have the expected results.  If I use that method, it adds the contact as a Linked Contact. So if I try and add that contact to another company it removes it from the original company that I added it to. 

 

I need the behavior that occurs if you are on a Company record, and you click Add/Remove Contacts.  This action allows you to add a contact to several different companies without effecting the contacts Parent Company or removing that contact from any other company's contact list.

 

Thanks again

 

 

Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Add Contact to Company via code

myCompany.SetStaticContacts(oFram.Contacts.GetContactAsCOntactLis(myContact));
myCompany.Update();
Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog