Associating and object to a custom object based on a property field
SOLVE
Hello All,
Anybody have a sample or a documentation for the below scenario? I want to associate a custom object to a deal based on whether a certain property field in the deal matches another property field in the custom object.
So for example: If deal.status = customobject.status, associate this custom objetc to the deal.
I am planning to do this through a js custom code, would really appreciate sharing some examples or documentations if any!
You have the objectId and when you run your search, you'll get the "toObjectId".
You're simply missing the objectTypes and to get them you can either make a call to get the object Schema of the object you're trying to associate OR you can also have a look at your settings :
If you go to your custom objects, open the "associations" tab, you'll see in the url : The objectType of your custom object will be the content of the url parameter "type" (in my case 2-1786212), and your toObjectType will be the content of the url parameter "selectToObjectTypeId" (in my case 0-1 for contacts).
There's an easier solution for you if you don't want to bother writing code : use the associ8 marketplace app, it lets you associate records based on a matching property.
It's free and so far I haven't had a problem with it.
Hope this helps ! If it does, please consider marking this answer as a solution 🙂
Best,
Ludwig
CTO @ Mi4 Hubspot Platinum Partner and Integration Expert
Passionate human, very curious about everything data and automation.
@ChrisChiha what you'll want to do is use the CRM Search API to find any existing deals with that matching property value. I'm a little nervous about matching on something like status, since I assume there could be multiple Deals that all have the same status value. If that's the case, you would probably want to add search criteria filters, to return on the specific deal you want. If there's a match the CRM Search API would return the ID of the Deal record, which you could then associate to your custom object.
I'm more of a Python guy, but this is how you could structure your CRM Search API request to find a Deal by status, written using Javascript Jquery:
Actually my main challenge is associating the custom object to the deal after i find the deal that has the matching property fied. I am using a custom object based workflow, and i am trying to associate the enrolled custom object to the deal i found.
You have the objectId and when you run your search, you'll get the "toObjectId".
You're simply missing the objectTypes and to get them you can either make a call to get the object Schema of the object you're trying to associate OR you can also have a look at your settings :
If you go to your custom objects, open the "associations" tab, you'll see in the url : The objectType of your custom object will be the content of the url parameter "type" (in my case 2-1786212), and your toObjectType will be the content of the url parameter "selectToObjectTypeId" (in my case 0-1 for contacts).
There's an easier solution for you if you don't want to bother writing code : use the associ8 marketplace app, it lets you associate records based on a matching property.
It's free and so far I haven't had a problem with it.
Hope this helps ! If it does, please consider marking this answer as a solution 🙂
Best,
Ludwig
CTO @ Mi4 Hubspot Platinum Partner and Integration Expert
Passionate human, very curious about everything data and automation.
Associating and object to a custom object based on a property field
SOLVE
Hi, @ChrisChiha👋 Thanks for reaching out. It's a great question. Let's see if we can get the conversation started. Hey @LMeert@Gonzalo@klloyd__1 have you tackled anything similar?