Hi, I need to assign a new company as a primary one. I do this in the automation, via a custom code. At first I start with removing the existing association and later set a new primary company. Everything looks fine in a log, but give no result - the new company is still no a Primary one. It would be great to understand what can be the issue.
I have those two steps
await hubspotClient.apiRequest({
method: ‘POST’,
path: ‘/crm/v4/associations/contacts/companies/batch/archive’,
body: companies.map(c => ({
from: { id: contactId },
to: [{ id: c.toObjectId }]
}))
});
await hubspotClient.apiRequest({
method: ‘PUT’,
path: `/crm/v4/objects/contact/${contactId}/associations/company/${bestCompanyId}`,
body: [
{ associationCategory: ‘HUBSPOT_DEFINED’, associationTypeId: 279 }, // default
{ associationCategory: ‘HUBSPOT_DEFINED’, associationTypeId: 1 } // primary
]
});
Could you suggest what can be wrong?