CMS Development

Manobyte
Contributor | Diamond Partner
Contributor | Diamond Partner

Display associated custom object records

SOLVE

I created the custom object "Jobs", I then created an association for Jobs to contacts. I would like to pull all associated jobs for the individual contact, only I seem to be running into an issue.

 

I have reviewed the documentation here for CRM associations , and I can make it pull a list of contacts associated with a job using {{ crm_associations(jobID, "USER_DEFINED", 17) }} but when I try to switch it to list jobs, nothing is returned. Is the "association type id" different if you invert them?

0 Upvotes
1 Accepted solution
Brownstephen101
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Display associated custom object records

SOLVE

Yes, the ID is different when you invert them, when you created your object it should have returned it's associations and their different ids. In the json, there should be a "From" and "To" key for each pairing. You have to make sure the ID you are using from the proper direction.

Example:

{
"fromObjectTypeId": "2-3444025",
"toObjectTypeId": "2-555555",
"name": "cat_to_dog"
}



If you dont have the json, you can run a "Read" request on your object to get the json again. Or, In my experience, the id will normally be 1 off of your current use case (so likely 16 or 18), so you could try to just update it that way and see if that works, but this isn't always the case.

https://developers.hubspot.com/docs/api/crm/crm-custom-objects

View solution in original post

1 Reply 1
Brownstephen101
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Display associated custom object records

SOLVE

Yes, the ID is different when you invert them, when you created your object it should have returned it's associations and their different ids. In the json, there should be a "From" and "To" key for each pairing. You have to make sure the ID you are using from the proper direction.

Example:

{
"fromObjectTypeId": "2-3444025",
"toObjectTypeId": "2-555555",
"name": "cat_to_dog"
}



If you dont have the json, you can run a "Read" request on your object to get the json again. Or, In my experience, the id will normally be 1 off of your current use case (so likely 16 or 18), so you could try to just update it that way and see if that works, but this isn't always the case.

https://developers.hubspot.com/docs/api/crm/crm-custom-objects