Has any one out there used a custom coded workflow to check for an - or ' in their first name, and to capitalise the first letter proceeding the - or '.
We've used the native data format action in a workflow to change all first names and last names to title case. But that's caused issues for the names that contain an - or '.
We can't find anything online to help troubleshoot this. Would be amazing if this use case was added to the Programmable Automation Use Cases ppage.
exports.main = async (event, callback) => {
// Pass firstname as a property to include in the code
let firstname = event.inputFields['firstname'];
// This will turn Lily-mae in Lily-Mae
if (firstname.includes('-')) {
const parts = firstname.split('-')
const firstPart = parts[0]
let secondPart = parts[1]
secondPart = secondPart.charAt(0).toUpperCase() + secondPart.slice(1);
firstname = firstPart + secondPart
}
// This will turn O'neil into O'Neil
if (firstname.includes("'")) {
const parts = firstname.split("'")
const firstPart = parts[0]
let secondPart = parts[1]
secondPart = secondPart.charAt(0).toUpperCase() + secondPart.slice(1);
firstname = firstPart + secondPart
}
// Define firstname as an output at the bottom to be able to use the 'copy to property action and save the firstname'
callback({
outputFields: {
firstname: firstname,
}
});
}
If you set 'firstname' as an output, you can use the copy to property action to store the firstname for this contact. I did not test this tho, so let me know if you run into any issues.
Learn more about HubSpot by following me on LinkedIn or YouTube
✅ Did my answer solve your issue? Help the community by marking it as the solution.
exports.main = async (event, callback) => {
// Pass firstname as a property to include in the code
let firstname = event.inputFields['firstname'];
// This will turn Lily-mae in Lily-Mae
if (firstname.includes('-')) {
const parts = firstname.split('-')
const firstPart = parts[0]
let secondPart = parts[1]
secondPart = secondPart.charAt(0).toUpperCase() + secondPart.slice(1);
firstname = firstPart + secondPart
}
// This will turn O'neil into O'Neil
if (firstname.includes("'")) {
const parts = firstname.split("'")
const firstPart = parts[0]
let secondPart = parts[1]
secondPart = secondPart.charAt(0).toUpperCase() + secondPart.slice(1);
firstname = firstPart + secondPart
}
// Define firstname as an output at the bottom to be able to use the 'copy to property action and save the firstname'
callback({
outputFields: {
firstname: firstname,
}
});
}
If you set 'firstname' as an output, you can use the copy to property action to store the firstname for this contact. I did not test this tho, so let me know if you run into any issues.
Learn more about HubSpot by following me on LinkedIn or YouTube
✅ Did my answer solve your issue? Help the community by marking it as the solution.