APIs & Integrations

PPipaliya
Member

How to set a custom object property value in HubSpot

How to set a custom object property value in HubSpot using HubSpotConversations. How to push or set a custom object property value in hubspot.

0 Upvotes
6 Replies 6
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

How to set a custom object property value in HubSpot

Is this code running in your client? If so, it would not be wise to run API calls from the client. You need a integration with listeners or use a workflow where you trigger a webhook or custom code.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
PPipaliya
Member

How to set a custom object property value in HubSpot

Yes, We used listeners, But how to set a custom object property value in javascript.

Like this:

window.HubSpotConversations.on('conversationStarted', () => {
                const _hsq = (window._hsq = window._hsq || []);
                _hsq.push([
                    'identify',
                    {
                        email: 'test@gmail.com',
                        // Here is how to set custom object property?
                    },
                ]);
0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

How to set a custom object property value in HubSpot

Hi @PPipaliya ,

 

Just to make sure I get this right;

Do you want to set a custom property for a contact?
Or do you want to set a property for a custom object?



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
PPipaliya
Member

How to set a custom object property value in HubSpot

Set a property value for a custom object.

0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

How to set a custom object property value in HubSpot

Hi!


This is described in the 'update' endpoint that is described in the endpoints tab in the custom object docs.

Here is a NodeJS example:

var http = require("https");

var options = {
  "method": "PATCH",
  "hostname": "api.hubapi.com",
  "port": null,
  "path": "/crm/v3/objects/<objectType>/<objectId>?hapikey=YOUR_HUBSPOT_API_KEY",
  "headers": {
    "accept": "application/json",
    "content-type": "application/json"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({
  properties: {
    property_string: 'value',
    property_number: '17',
    property_date: '1572480000000',
    property_radio: 'option_1',
    property_dropdown: 'choice_b',
    property_checkbox: 'false',
    property_multiple_checkboxes: 'chocolate;strawberry'
  }
}));
req.end();


Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
PPipaliya
Member

How to set a custom object property value in HubSpot

How to set a custom object property value in HubSpot when the user started conversation in chatflow?.

window.HubSpotConversations.on('conversationStarted', () => {
// I need to set a custom object property value 
}
0 Upvotes