Last active
June 13, 2024 13:21
-
-
Save jackcoldrick90/6d854d0fe41a8b564bb4341f458d1bd2 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = results.body.properties.full_name; | |
let splitName = fullName.split(" "); | |
callback({ | |
outputFields: { | |
firstName: splitName[0], | |
lastName: splitName[1] | |
} | |
}); | |
}) | |
.catch(err => { | |
console.error(err); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an outdated code, should be using accesscode, not APIkey