It’s possible to include more options to a field created by HubSpot using only the API?
For example, for “Buying Role” field, I want to add 2 more options.
I’m using the V3 of the API (Ruby gem) and there is no option to add new options to a field already created by HubSpot, I always see errors and validation messages as a response from API.
Can you post your request body?
You can add/change options, but you cannot modify the definition. There must be something wrong with the json you submitted. here is an example of a request I just made where I added “other thing” as an additional option
{
"updatedAt": "2020-05-14T12:28:15.119Z",
"createdAt": "2019-10-04T19:45:40.870Z",
"name": "hs_buying_role",
"label": "Buying Role",
"type": "enumeration",
"fieldType": "checkbox",
"description": "The role that a contact plays during the sales process. Contacts can have more than one role, and they can share the same role with another contact.",
"groupName": "contactinformation",
"options": [
{
"label": "Blocker",
"value": "BLOCKER",
"displayOrder": -1,
"hidden": false
},
{
"label": "Budget Holder",
"value": "BUDGET_HOLDER",
"displayOrder": -1,
"hidden": false
},
{
"label": "Champion",
"value": "CHAMPION",
"displayOrder": -1,
"hidden": false
},
{
"label": "Decision Maker",
"value": "DECISION_MAKER",
"displayOrder": -1,
"hidden": false
},
{
"label": "End User",
"value": "END_USER",
"displayOrder": -1,
"hidden": false
},
{
"label": "Executive Sponsor",
"value": "EXECUTIVE_SPONSOR",
"displayOrder": -1,
"hidden": false
},
{
"label": "Influencer",
"value": "INFLUENCER",
"displayOrder": -1,
"hidden": false
},
{
"label": "Legal & Compliance",
"value": "LEGAL_AND_COMPLIANCE",
"displayOrder": -1,
"hidden": false
},
{
"label": "Other",
"value": "OTHER",
"displayOrder": -1,
"hidden": false
},
{
"label": "Other thing",
"value": "OTHER thing",
"displayOrder": -1,
"hidden": false
}
],
"displayOrder": -1,
"calculated": false,
"externalOptions": false,
"hasUniqueValue": false,
"hidden": false,
"modificationMetadata": {
"archivable": true,
"readOnlyDefinition": true,
"readOnlyOptions": false,
"readOnlyValue": false
},
"formField": false
}
Ok, I didn’t send all the other options, I have just sent in the JSON the ones that I wanted to include.
I’m gonna try with this one and I’ll let you know the results.
You might be able to get away with just sending the options. I didn’t test that. I sent the whole thing back ![]()
I had to pass everything to the request, but finally, I was able to make this work.
I’ll include the code examples here for people looking for doing something similar using HubSpot Ruby Gem.
params = { “name”: ‘hs_buying_role’, “label”: ‘Buying Role’, “type”: ‘enumeration’, “fieldType”: ‘checkbox’, “description”: ‘The role that a contact plays during the sales process. Contacts can have more than one role, and they can share the same role with another contact.’, “groupName”: ‘contactinformation’, “options”: [ { “label”: ‘Blocker’, “value”: ‘BLOCKER’, “displayOrder”: -1, “hidden”: false }, { “label”: ‘Budget Holder’, “value”: ‘BUDGET_HOLDER’, “displayOrder”: -1, “hidden”: false }, { “label”: ‘Champion’, “value”: ‘CHAMPION’, “displayOrder”: -1, “hidden”: false }, { “label”: ‘Decision Maker’, “value”: ‘DECISION_MAKER’, “displayOrder”: -1, “hidden”: false }, { “label”: ‘End User’, “value”: ‘END_USER’, “displayOrder”: -1, “hidden”: false }, { “label”: ‘Executive Sponsor’, “value”: ‘EXECUTIVE_SPONSOR’, “displayOrder”: -1, “hidden”: false }, { “label”: ‘Influencer’, “value”: ‘INFLUENCER’, “displayOrder”: -1, “hidden”: false }, { “label”: ‘Legal & Compliance’, “value”: ‘LEGAL_AND_COMPLIANCE’, “displayOrder”: -1, “hidden”: false }, { “label”: ‘Other’, “value”: ‘OTHER’, “displayOrder”: -1, “hidden”: false }, { “label”: ‘Billing Contact’, “value”: ‘BILLING_CONTACT’, “displayOrder”: -1, “hidden”: false }, { “label”: ‘Shipping Contact’, “value”: ‘SHIPPING_CONTACT’, “displayOrder”: -1, “hidden”: false } ], “displayOrder”: -1, “calculated”: false, “externalOptions”: false, “hasUniqueValue”: false, “hidden”: false, “modificationMetadata”: { “archivable”: true, “readOnlyDefinition”: true, “readOnlyOptions”: false, “readOnlyValue”: false }, “formField”: false }
::Hubspot.configure do |config|
config.access_token = hubspot.auth_keys.access_token
end
service = ::Hubspot::Crm::Properties::CoreApi.new
service.update(‘contact’, params[:name], params, auth_names: ‘oauth2’)