<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need to query all custom objects associated to a contact and pull a single property from each in Data Hub</title>
    <link>https://community.hubspot.com/t5/Data-Hub/Need-to-query-all-custom-objects-associated-to-a-contact-and/m-p/1022704#M2501</link>
    <description>&lt;P&gt;hey there&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/803220"&gt;@JErickson60&lt;/a&gt;&amp;nbsp;you can do this with a custom code action via the API:&lt;BR /&gt;1. use this endpoint to retrieve all of the associated Buildings of a the enrolled Contact (by Record ID)&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/api/crm/associations/v3#:~:text=Retrieve%20associations,values%20for%20all%20associated%20deals" target="_blank"&gt;https://developers.hubspot.com/docs/api/crm/associations/v3#:~:text=Retrieve%20associations,values%20for%20all%20associated%20deals&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;2. use this endpoint to read the Building ID property value from the specified Building by including its record ID.&amp;nbsp; Endpoint:&amp;nbsp;&lt;SPAN&gt;/crm/v3/objects/{objectType}/{objectId}&lt;/SPAN&gt;&lt;BR /&gt;Docs:&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/api/crm/crm-custom-objects" target="_blank"&gt;https://developers.hubspot.com/docs/api/crm/crm-custom-objects&lt;/A&gt;&lt;/P&gt;&lt;P&gt;3. use this endpoint to update (append the Building ID) the contact's property for storing the associated Building ID(s).&lt;/P&gt;&lt;P&gt;Endpoint:&amp;nbsp;PATCH/crm/v3/objects/contacts/{contactId}&lt;BR /&gt;Docs:&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/api/crm/contacts" target="_blank"&gt;https://developers.hubspot.com/docs/api/crm/contacts&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's documentation on how to use Custom Code Actions in HubSpot:&lt;BR /&gt;&lt;A href="https://developers.hubspot.com/docs/api/workflows/custom-code-actions" target="_blank"&gt;https://developers.hubspot.com/docs/api/workflows/custom-code-actions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Aug 2024 09:12:12 GMT</pubDate>
    <dc:creator>RThomas7</dc:creator>
    <dc:date>2024-08-06T09:12:12Z</dc:date>
    <item>
      <title>Need to query all custom objects associated to a contact and pull a single property from each</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Need-to-query-all-custom-objects-associated-to-a-contact-and/m-p/1019724#M2495</link>
      <description>&lt;P&gt;Need to query all custom objects associated to a contact and pull a single property from each one to add to a contact.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So we have custom objects called "Buildings" and a given contact can have multiple "Buildings" Associated. I need to know if i can use a workflow to query all associated "Buildings", not just most recently updated, and pull a single property, "Building ID" to be able to add it to a property on the contact record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this cannot be done via regular workflow does anyone know by chance if a custom coded api workflow can achieve this?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 20:55:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Need-to-query-all-custom-objects-associated-to-a-contact-and/m-p/1019724#M2495</guid>
      <dc:creator>JErickson60</dc:creator>
      <dc:date>2024-07-31T20:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Need to query all custom objects associated to a contact and pull a single property from each</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Need-to-query-all-custom-objects-associated-to-a-contact-and/m-p/1020071#M2499</link>
      <description>&lt;P&gt;Hey &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/803220"&gt;@JErickson60&lt;/a&gt;&lt;/SPAN&gt;, welcome to our Community!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To query all custom objects (like "Buildings") associated with a contact and pull a single property (such as "Building ID") to add to a contact's record, you can't do this directly with HubSpot's native workflows.&lt;/P&gt;
&lt;P&gt;However, you can use custom coded workflow actions. Here's a brief overview:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
 &lt;LI&gt;Create a custom coded action in your workflow.&lt;/LI&gt;
 &lt;LI&gt;Use HubSpot's API to get all custom objects associated with the contact and extract the "Building ID" from each.&lt;/LI&gt;
 &lt;LI&gt;Update the contact record with the collected "Building IDs".&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;To our top experts, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/76319"&gt;@DanielSanchez&lt;/a&gt;&lt;/SPAN&gt; and &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/17186"&gt;@Anton&lt;/a&gt; do you have any recommendations for &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/803220"&gt;@JErickson60&lt;/a&gt;&lt;/SPAN&gt; matter?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Pam&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 14:07:57 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Need-to-query-all-custom-objects-associated-to-a-contact-and/m-p/1020071#M2499</guid>
      <dc:creator>PamCotton</dc:creator>
      <dc:date>2024-08-01T14:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need to query all custom objects associated to a contact and pull a single property from each</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Need-to-query-all-custom-objects-associated-to-a-contact-and/m-p/1020435#M2500</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/803220"&gt;@JErickson60&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To start &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/60427"&gt;@PamCotton&lt;/a&gt; 's ideas are the right direction, to paint a little more context:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the &lt;A href="https://developers.hubspot.com/docs/cms/data/query-hubspot-data-using-graphql#use-a-graphql-query-in-an-api-request" target="_blank" rel="noopener"&gt;graphql API&lt;/A&gt; to get all buildings w/ the building_id property associate to a contact in a workflow:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;query MyQuery {
  CRM {
    contact(uniqueIdentifier: "hs_object_id", uniqueIdentifierValue: "44139400962") {
      associations {
        p_buildings_collection__contact_to_buildings {
          items {
            building_id
          }
        }
      }
    }
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;This query is requesting all buildings&amp;nbsp; w/ their building_ids associated to contact with a record ID of&amp;nbsp; "44139400962".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The response will look somethign like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
"data": {
    "CRM": {
      "contact": {
        "associations": {
          "p_buildings_collection__contact_to_buildings": {
            "items": [
              {
                "building_id": "6565"
              },
              {
                "building_id": "34232"
              }
            ]
          }
        }
      }
    }
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then loop throught the buildings to output a list of the bulding IDs:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;const buildingIds = response.data.CRM.Contact.Associations.p_buildings_collection__contact_to_buildings.items.map(obj =&amp;gt; obj.building_id);&lt;/LI-CODE&gt;
&lt;P&gt;Finnaly this can then be output from the custom code action and applied to the contact record property.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now if you only want a single&amp;nbsp; building_id you'll need additional logic to determine which building_id is the correct ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this gets you going!&lt;/P&gt;
&lt;P&gt;If I can clarify or help further in any way please don't hesitate to reach out!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 02:52:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Need-to-query-all-custom-objects-associated-to-a-contact-and/m-p/1020435#M2500</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2024-08-02T02:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need to query all custom objects associated to a contact and pull a single property from each</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Need-to-query-all-custom-objects-associated-to-a-contact-and/m-p/1022704#M2501</link>
      <description>&lt;P&gt;hey there&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/803220"&gt;@JErickson60&lt;/a&gt;&amp;nbsp;you can do this with a custom code action via the API:&lt;BR /&gt;1. use this endpoint to retrieve all of the associated Buildings of a the enrolled Contact (by Record ID)&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/api/crm/associations/v3#:~:text=Retrieve%20associations,values%20for%20all%20associated%20deals" target="_blank"&gt;https://developers.hubspot.com/docs/api/crm/associations/v3#:~:text=Retrieve%20associations,values%20for%20all%20associated%20deals&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;2. use this endpoint to read the Building ID property value from the specified Building by including its record ID.&amp;nbsp; Endpoint:&amp;nbsp;&lt;SPAN&gt;/crm/v3/objects/{objectType}/{objectId}&lt;/SPAN&gt;&lt;BR /&gt;Docs:&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/api/crm/crm-custom-objects" target="_blank"&gt;https://developers.hubspot.com/docs/api/crm/crm-custom-objects&lt;/A&gt;&lt;/P&gt;&lt;P&gt;3. use this endpoint to update (append the Building ID) the contact's property for storing the associated Building ID(s).&lt;/P&gt;&lt;P&gt;Endpoint:&amp;nbsp;PATCH/crm/v3/objects/contacts/{contactId}&lt;BR /&gt;Docs:&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/api/crm/contacts" target="_blank"&gt;https://developers.hubspot.com/docs/api/crm/contacts&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's documentation on how to use Custom Code Actions in HubSpot:&lt;BR /&gt;&lt;A href="https://developers.hubspot.com/docs/api/workflows/custom-code-actions" target="_blank"&gt;https://developers.hubspot.com/docs/api/workflows/custom-code-actions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 09:12:12 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Need-to-query-all-custom-objects-associated-to-a-contact-and/m-p/1022704#M2501</guid>
      <dc:creator>RThomas7</dc:creator>
      <dc:date>2024-08-06T09:12:12Z</dc:date>
    </item>
  </channel>
</rss>

