We've written a "Custom Code" Action we'd like to share that can help you generate short, unique IDs directly within your HubSpot workflows. This can add a layer of unique identification to your data without needing to get bogged down in complex coding.
Why Use Unique, Short IDs?
Think of these IDs as custom labels for your data. They're perfect for:
Keeping Track of Customer Data: Easily identify and manage specific records within your customer data, making analysis more accurate.
Streamlining Processes: Create short tracking codes to monitor and track your customer data within your business processes.
Connecting HubSpot to Other Tools: If you're syncing data between HubSpot and other apps, these IDs act as a reliable link, ensuring everything stays organized.
General data organization: If you have any need for a unique identifier in your workflows, this tool can help.
How Does It Work?
We've written a small piece of code that generates 8-character, unique IDs. It's designed to be used directly inside HubSpot's workflow actions, so you don't need to be a coding expert.
Add a "Custom Code" Action: In your HubSpot workflow, look for the "Custom Code" action and add it.
Copy and Paste: Copy the code from the GitHub link and paste it into the "Custom Code" action.
Tell HubSpot Where to Store the ID: You'll need to tell HubSpot where you want to save the generated ID (e.g., a custom property).
Use the ID in Your Workflow: Now, you can use that unique ID in other steps of your workflow.
Example Workflow use case:
We recently faced a situation where we needed to share and sync customer data across multiple applications. To ensure consistent customer identification and the ability to update the data across these systems, we required a reliable, cross-domain ID.
We implemented a workflow that generates a unique 8-character ID whenever a new customer is created in HubSpot. This ID is then pushed to all other applications. This ensures that when a customer interacts with any of the applications, we can easily trace their journey and update their information across all platforms. This solution helped us achieve a unified view of our customer data and streamline our data management.
Why 8 Characters?
8 characters is the sweet spot. It's short enough that you can actually remember it, which is incredibly helpful when you're working with data across different systems. This human-friendly length makes it easier to reference and work with, unlike those long, unwieldy standard UUIDs.
Try It Out!
This code is free to use. Give it a try and let us know how you're using it! We welcome and appreciate all feedback and contributions.
The custom code will only output the generated short UUID. Therefore, you'll need to add a second step to your workflow to edit (update) your record. Attached is an example of a workflow that adds the generated short UUID to a newly created company record.
If you're still having trouble, just send me a message.
Thanks for providing the generate_uuid.py script. I’ve implemented it as a custom code action in a HubSpot workflow, and it executes successfully. I also made sure to define short_uuid in the Data Outputs panel with a String type, as instructed.
However, after the code runs, I’m unable to access the short_uuid output in subsequent workflow steps (e.g., when trying to copy it into a contact or deal property). It doesn’t appear in the list of available outputs, even though the code runs without errors.
I also tried hardcoding the output value to ensure the issue wasn’t with the UUID generation, but the behavior persists.
Could you please help verify if the structure of the callback({"outputs": {"short_uuid": short_uuid}}) response is compatible with the current HubSpot environment, or if any adjustments are needed to make the output accessible in other steps?
The custom code will only output the generated short UUID. Therefore, you'll need to add a second step to your workflow to edit (update) your record. Attached is an example of a workflow that adds the generated short UUID to a newly created company record.
If you're still having trouble, just send me a message.
Hi @rverheijen! Welcome to the Community-- happy to have you here 😊 Thank you so much for sharing this code! I am sure so many HubSpot customers will find value here!
HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates. Learn More.
Did you know that the Community is available in other languages? Join regional conversations by changing your language settings !