I’m trying to create a custom code workflow that would create a record onto the custom object. Copying properties from the line items to populate the properties within the new custom object record.
I’m currently struggling with how to post these onto the custom object, as I can’t figure out how the data model is setup to access the custom object.
Any assistance/advice with this would be greatly appreciated.
At a high level, you would want to create a Deal workflow, with whatever enrollment triggers you need.
Then, in your code, you would want to make 2 API calls:
The first API call would be to pull the line items associated with the deal enrolled in the workflow. You can pass in the Record ID for this, as a variable. You can use this page as your reference - specifically the endpoint for List. This will give you any line items. (If you don’t know how to reference {objectType}, see below)
You then want to store these results as variables for the next step.
For your second API call, you want to connect to the custom object endpoint - specifically the one in the Objects tab listed with Create. You will need the identifier for your custom object. You can find it in your portal by clicking the Contacts dropdown and selecting your custom object. The URL will look like this:
The part marked [your custom object ID] will be used where the API documentation asks for {objectType}. This is true for any other object you are trying to reference, such as Contacts or Deals. The Create endpoint allows you to add properties to the payload. This is where you want to use those variables with the line item data, to place them wherever you need.
When using the JS code I currently have, how would I adjust this expression to access the properties within the custom object? hubspotClient.crm.objects.basicApi.create
When I attempted to use the custom object ID to create a record, I kept getting errors when testing this method.
hubspotClient.crm.2-19018666.basicApi.create
Can you please let me know where I’m going wrong with this?