Property sync with association label

Having some trouble with association labels. We have an association on our company object that is Main firm and DBA. A main firm can have many DBAS but a DBA can only have one main firm. On the DBA record we have a field called main firm that is auto populated correctly. However we need a main firm field on the Main firm company that shows the name of that main firm however a property sync wont work since we are creating multiple the most recently doesn’t pick this up. Any help on how we can achieve this?

If I’m following your issue correctly, rather than using association labels you may want to use a property value on the record that is multi select so it won’t be overwritten with the latest value? That may work better for you for the main firm.

If I missed your goal, let me know- happy to revisit other options!

So multi select won’t work just because we have to constantly update with each company name. So we have to use the label to drive this.

Hey @cclark2,
Thanks for following up here!

Re-tagging @rebeccatravels for visibility!
Shane, Senior Community Moderator

I’m curious how often you update these company names (you said “often”- is that hourly? daily? weekly? monthly?)?

If more like weekly/monthly, you could use the multi select. If there is a specific action that would be associated with re-enrolling users in a workflow (every time you do x, you also update the company names- assuming you are updating other info at the same time?), you could first clear the property, then edit the record with the new, current multi-select options. This assumes though that it’s a closed list of companies and not adding new ones regularly.

With some more detail, as you can see from this thread there are a few approaches… but association labels are likely not the best option for you since they will be overwritten.

Hi @cclark2,

Just to confirm and rephrase your query, you would like to have a sync property on the company object that doesn’t just reflect the name of first created or most recently updated DBA, but all of their names?

If so, this is currently not possible with sync properties / association labels.

There are ways to configure this with workflows and assisting properties but they are unreliable. The approach would generally be to re-enroll DBA companies into a workflow whenever the number of associated DBA companies on the main firm changes, then use ‘Edit record’ to append the company name to a field on the main firm. Since it involves many changes to a single field over the course of a couple of seconds, it’s not something I’d advise.

There are also options via custom development and the API to push the names of associated DBA companies into a custom property. This would require someone with development skills and understanding of the HubSpot API.

Considering that neither of these routes is something I’d personally prefer, could you explain what exactly you’re trying to achieve by having these company names in a single field? The information is right there in the right sidebar, easily accessible.

Best regards

Hello @cclark2 ,
We can solve this by creating two separate company-based workflows :
Workflow 1: Update the main firm field in DBAs.
- Create workflow
- Click “Trigger manually”
- Select the company and click “save and continue”
- Select the “When filter criteria are met”
- In “Only enrol companies that meet these conditions”, click on “Add Criteria”
- In the filter, select the “Company (Associated Object)” and the “Company properties,” then choose the “Record ID” to be known.
- And in the company, select “Main firm”. Association.
- And in action, firstly, add a 2-minute delay. And update the main firm HubSpot field with the Company name property of the associated Company: Main firm.

Here are screenshots :

Workflow 2: Update the main firm when companies create
- Create workflow

- Click “Trigger manually”
- Select the company and click “save and continue”
- Select the “When filter criteria are met”
- Select the Company property and choose the “Record ID” to be known.
- And in action, the main firm HubSpot field with the Company name property.
Here are the screenshots:

Thanks,
Shubham Mishra

@shubham_capl how is this accounting for the multiple companies (DBA) that can be associated with a main firm? Your workflow would not concatenate these multiple DBA on the main firm, it would simply overwrite them.

What you’re describing can be handled more easily through a sync property. However, the challenge is exactly that it’s not just one company, but multiple.

@karstenkoehler, I may have understood the requirement a bit differently initially, so thanks for correcting me :slightly_smiling_face:
You’re absolutely right, my workflow approach would overwrite values instead of concatenating multiple DBA companies associated with the Main Firm.
For this use case, the better approach would be to use a custom-coded workflow action.
@cclark2 , you can follow these workflow steps. Please see the screenshot below:

Here is the Node.js code for custom code :

const hubspot = require('@hubspot/api-client');

exports.main = async (event, callback) => {
 const hubspotClient = new hubspot.Client({
 accessToken: process.env.privateAppToken,
 });

 const DBAS_ASSOCIATION_TYPE_ID = 1;
 const MAIN_FIRM_ASSOCIATION_TYPE_ID = 2;

 try {
 const companyId = String(event.object.objectId);

 // Get current enrolled company details
 const currentCompanyRes = await hubspotClient.crm.companies.basicApi.getById(
 companyId,
 ['name']
 );
 const currentCompanyName = currentCompanyRes.properties?.name || '';

 // STEP 1: find Main Firm associated to this DBA
 const associatedCompanies =
 await hubspotClient.crm.associations.v4.basicApi.getPage(
 'companies',
 companyId,
 'companies'
 );

 if (!associatedCompanies.results?.length) {
 return callback({
 outputFields: {
 dba_list: 'No associated Main Firm found',
 },
 });
 }

 const mainFirmAssociation = associatedCompanies.results.find((assoc) =>
 (assoc.associationTypes || []).some(
 (type) => Number(type.typeId) === MAIN_FIRM_ASSOCIATION_TYPE_ID
 )
 );

 if (!mainFirmAssociation) {
 return callback({
 outputFields: {
 dba_list: 'Main Firm association not found',
 },
 });
 }

 const mainFirmId = String(mainFirmAssociation.toObjectId);

 // STEP 2: get all companies associated to Main Firm
 const mainFirmAssociations =
 await hubspotClient.crm.associations.v4.basicApi.getPage(
 'companies',
 mainFirmId,
 'companies'
 );

 let dbaCompanyIds = (mainFirmAssociations.results || [])
 .filter((assoc) =>
 (assoc.associationTypes || []).some(
 (type) => Number(type.typeId) === DBAS_ASSOCIATION_TYPE_ID
 )
 )
 .map((assoc) => String(assoc.toObjectId))
 .filter((id) => id !== mainFirmId);

 // Force include current DBA if missing
 if (!dbaCompanyIds.includes(companyId)) {
 dbaCompanyIds.push(companyId);
 }

 // Deduplicate
 dbaCompanyIds = [...new Set(dbaCompanyIds)];

 if (!dbaCompanyIds.length) {
 return callback({
 outputFields: {
 dba_list: '',
 },
 });
 }

 // STEP 3: fetch names
 const companiesResponse = await hubspotClient.crm.companies.batchApi.read({
 inputs: dbaCompanyIds.map((id) => ({ id })),
 properties: ['name'],
 });

 let dbaNames = (companiesResponse.results || [])
 .map((company) => company.properties?.name)
 .filter(Boolean);

 // Force include current company name if API read-back was stale
 if (currentCompanyName && !dbaNames.includes(currentCompanyName)) {
 dbaNames.push(currentCompanyName);
 }

 dbaNames = [...new Set(dbaNames)].sort((a, b) => a.localeCompare(b));

 const dbaList = dbaNames.join(', ');

 return callback({
 outputFields: {
 dba_list: dbaList,
 },
 });
 } catch (error) {
 console.error(
 'Custom code error:',
 error.response?.body || error.message || error
 );

 return callback({
 outputFields: {
 dba_list: `Error: ${error.message || 'Unknown error'}`,
 },
 });
 }
};

You will this results :

@karstenkoehler, I learned a lot from your explanation and solution on the HubSpot community. I really appreciate you taking the time to explain it. Big fan of the approach :raising_hands:

And if you think there’s a better or more scalable way to handle this, I’m happy to learn more from you as well.
Always open to improving my understanding and approach :slightly_smiling_face:

So we have two association labels Main firm(Parent) and DBA(Child). We need certain fields to automatically be associated to the DBA (Child) firms when they are associated. The fields we need copied are drop down fields so we can’t use a property sync because the parent firms are created first manually and the child firms get added down the line. What is a workflow to achieve this?

Hello @cclark2 ,
You can use this workflow: Update the main firm field in DBAs. I’m attaching some screenshots below :

And it will work like this :