HubSpot.NET icon indicating copy to clipboard operation
HubSpot.NET copied to clipboard

Associate Contact with Existing Deal

Open TimWhitbeck opened this issue 6 years ago • 5 comments

I can create a new deal with a contact, that works great but when attempting to use the deal update and try to add a contact I am missing something.

code snippet: var deal=api.Deal.GetById<DealHubSpotModel>(dealId); var contact = api.Contact.GetByEmail<ContactHubSpotModel>(contact.Email); deal.Associations.AssociatedContacts=new []{contact.Id.Value}; api.Deal.Update(deal); This succeeds but when I check hubspot there is no associated contact

TimWhitbeck avatar Feb 19 '19 19:02 TimWhitbeck

Hi! What version of HubSpot.NET are you using?

Psypher9 avatar Feb 20 '19 14:02 Psypher9

0.6.17

TimWhitbeck avatar Feb 20 '19 15:02 TimWhitbeck

Hi @TimWhitbeck, I think that I will try to add an easier way to associate the contacts with the deal. Possibl add a dedicated method to the Deal. Thank you again for bringing this up!

Psypher9 avatar Jun 09 '19 02:06 Psypher9

I coded it like this and it works.

DealHubSpotModel deal = HsAPI.Deal.Create(new DealHubSpotModel() { Associations = { AssociatedContacts = new[] { lHsVid } }, /* lHsVid is Contact Vid */ Name = "Super Product" }); lDealid = (long)deal.Id; // Get back deal.id

ricktiger avatar May 05 '20 19:05 ricktiger