Need to query all custom objects associated to a contact and pull a single property from each

Hey @JErickson60

To start @PamCotton 's ideas are the right direction, to paint a little more context:

You can use the graphql API to get all buildings w/ the building_id property associate to a contact in a workflow:

query MyQuery {
 CRM {
 contact(uniqueIdentifier: "hs_object_id", uniqueIdentifierValue: "44139400962") {
 associations {
 p_buildings_collection__contact_to_buildings {
 items {
 building_id
 }
 }
 }
 }
 }
}

This query is requesting all buildings w/ their building_ids associated to contact with a record ID of “44139400962”.

The response will look somethign like:

{
"data": {
 "CRM": {
 "contact": {
 "associations": {
 "p_buildings_collection__contact_to_buildings": {
 "items": [
 {
 "building_id": "6565"
 },
 {
 "building_id": "34232"
 }
 ]
 }
 }
 }
 }
 }
}

You can then loop throught the buildings to output a list of the bulding IDs:

const buildingIds = response.data.CRM.Contact.Associations.p_buildings_collection__contact_to_buildings.items.map(obj => obj.building_id);

Finnaly this can then be output from the custom code action and applied to the contact record property.

Now if you only want a single building_id you’ll need additional logic to determine which building_id is the correct ID.

Hope this gets you going!

If I can clarify or help further in any way please don’t hesitate to reach out!