Add choice field options dynamically

Hello Everyone,I am currently working in the HubSpot Design Manager, where I am fetching and rendering data. When I switch to the Design Previewer, I can see the rendered data perfectly.
I have manually added a choice field using the “Add Fields” option in the module and provided the required options manually. This field also renders correctly in the previewer.
What I want to achieve is to dynamically add options to this choice field through the code I am writing in the Design Manager, instead of adding the options manually.
Is it possible to achieve this? If so, how can I accomplish it? Any help would be greatly appreciated.

I would suggest looking into Custom coded workflows if your tier allows this. In addition where would this dynamic data be pulled from ?

i am pulling this dynamic data from the lists where all my products are residing

I assume this is HubSpot lists ? If so , I would suggest using the HubSpot List API to retrieve the values. You should be able to do this within the module using JS.

Hi @RTeja,

the only thing that might be possible is to utilize the Modules API but to be honest, I’ve never done that and it might not be the right thing.
Besides that the only proven option would be to keep manually typing in those options.

Just out of interest - what are you trying to achieve? Maybe there are different approaches you can take a look at

best,

Anton

Yeah i am still looking for the approaches that can solve this problem and the last option is manually typing in those options​:hugs:

Than I’d suggest to use HubDB (available in Marketing/Content professional and Enterprise) or Custom objects (only in Enterprise).

Quick list of pros/cons for each of those options

HubDB is good for:

  • data management
  • dynamic pages
  • Multi-level content
  • relational data

HubDB is not good for:

  • Structured content that is also critical business data to be used in associations, reporting, automation
  • Data that has more than 10k record

Custom objects are good for:

  • Structured business data that is also used on the website
  • Content needs to be associated with CRM data, or used in reporting and automation
  • Data sources where you need more than 10k instances

Custom objects are not good for:

  • Content that needs a content focused editor and richer properties
  • Content that should not be showing up throughout the CRM, reporting, automation, associations, etc.
  • Customers who do not have Enterprise

We had our very first Developer HUG about exactly this topic.
Here’s the recording if you’re interested to learn more and see an example of the same “requirement” build in HubDB and Custom Objects.

In case you did not know:
HubDB can be edited by CSV/XLS(X)

hope that helps

best,

Anton

@RTeja - I’ve done quite a bit of work like this recently creating and maintaining dynamic dropdown lists for form entry. A typical case would be offering a dropdown of all available car model types, created by scanning for unique options in a master database (custom object or HubDB table). This type of function can be set up in a custom coded workflow step where the existing and incremental new values are combined before patching the object property.

Steve

Can you please be a bit more brief about this approach?

Hi @RTeja,

You’re adding a choice field in a module right? if that’s the case you likely won’t be able to dynamically add options to the choice field.

If it’s possible to move the choice field to template level in your use case you might have more options.
To futher inform my answer could you provide an example of what would be creating the dynamic options?


Barry Grennan

Freelance HubSpot CMS Developer

Website | Contact | LinkedIn

Yeah, you are right, the choice field I am adding is from the module. What do you mean by moving the choice field to the template level? You want me to add the manual select field in the code that I am writing for the template in the design manager?