Skip to content

Instantly share code, notes, and snippets.

Last active May 10, 2022 19:28
What would you like to do?
Using Hubspot Operations Hub Custom Coded workflow action you can split the full name provided by a contact and store in the firstname and lastname properties. Ideal if you're asking for the entire name in a single field on the form.
const hubspot = require('@hubspot/api-client');
exports.main = (event, callback) => {
const hubspotClient = new hubspot.Client({
apiKey: process.env.HAPIKEY
hubspotClient.crm.contacts.basicApi.getById(event.object.objectId, ["full_name"])
.then(results => {
let fullName =;
let splitName = fullName.split(" ");
outputFields: {
firstName: splitName[0],
lastName: splitName[1]
.catch(err => {
Copy link

@jackcoldrick90 Could this be altered to extract first and last name from an email address provided it follows the standard So basically ignore anything after @ and then use the "." as the delimiter similar to your " " above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment