Iâm creating a workflow that checks whether a deal has a primary company label or not, and then it adds the deals to an active list to be manually reviewed. When I run test cases through the workflow, they all move through ânone metâ when they should be moving through the âyesâ or ânoâ branches, so I think it has something to do with the property not being accessible. I created a property to store a boolean for this workflow and it hasnât been populated by any other means. Iâve declared the right data output by naming the property and the boolean datatype, and the output is in the form of a dictionary. The code is listed below:
import requests
PRIMARY_LABEL_ID = 1
def get_headers(api_key):
return {
âAuthorizationâ: fâBearer {api_key}',
âContent-Typeâ: âapplication/jsonâ
}
def get_company_associations(deal_id, headers):
url = fâhttps://api.hubapi.com/crm/v4/objects/deals/{deal_id}/associations/companiesâ
params = {âlimitâ: 100}
response = requests.get(url, headers=headers, params=params)
response.raise_for_status()
return response.json().get(âresultsâ, [])
def has_primary_company(associations):
for assoc in associations:
label_ids = assoc.get(âassociationSpecâ, {}).get(âlabelIdsâ, assoc.get(âlabelIdsâ, []))
if PRIMARY_LABEL_ID in label_ids:
return âYesâ
return âNoâ
def main(input):
deal_id = input.get(âinputFieldsâ, {}).get(âhs_object_idâ)
api_key = âpat-na1-e08350ef-4f05-4dd1-8295-3d398d3fcd47â # replace with secure token in production
if not api_key:
return {
âoutputFieldsâ: {
âprimary_company_associatedâ: âNoâ,
âerrorâ: âMissing HubSpot access token in secretsâ
}
}
if not deal_id:
return {
âoutputFieldsâ: {
âprimary_company_associatedâ: âNoâ,
âerrorâ: âMissing hs_object_id input fieldâ
}
}
try:
headers = get_headers(api_key)
associations = get_company_associations(deal_id, headers)
is_primary = has_primary_company(associations)
return {
âoutputFieldsâ: {
âprimary_company_associatedâ: is_primary,
âerrorâ: âYAY! no errorâ # always include error field for consistency
}
}
except Exception as e:
return {
âoutputFieldsâ: {
âprimary_company_associatedâ: âNoâ,
âerrorâ: str(e)
}
}
issue workflow (unresponsive UI)
correct workflow (responsive UI)
property settings



