I’m setting up formatter: split text to separate a full name field into a first and last name field. I am using the Segment Index: All (as Separate Fields). This is my setup:
First Name: Item 1
Last Name: Item 2
I think it will work great when people just enter a first and last name:
First Name: Stephen
Last Name: Strange
My fear is that people will occasionally enter titles and additional names. Would Dr. Stephen Vincent Strange become:
First Name: Dr.
Last Name: Stephen
Would I lose all of the extra data? What is the best practice here? Without some sort of name-parsing AI - I think the best outcome would be letting the extra fields get added to the last name field somehow. What would that look like?
or is there an option to pass text with more than 2 segments in a different way? I could have these flagged for manual review into our CRM.
And if any of this is possible will it require a lot of extra tasks? The way I have it set up - it should just be one task.
Any best practices or tips / tricks would be appreciated!
Page 1 / 1
Hi
Good question.
Check out this topic:
I’m not super confident in my JavaScript, but I think this modified version of your code should split 2 part names and pass longer names to us in a separate field for manual entry (our CRM will alert us).
const WordCount = inputData.NameFull.trim().split(' ').length; // counts full name words
if (WordCount > 2) {
let NameError = "Manual entry required: " + inputData.NameFull; // adds manual entry note to full name
output = u{NameError}];
} else {
let NameFull = inputData.NameFull.trim().split(' '); // removes whitespace and splits by spaces
let NameFirst = NameFulle0]; // takes first array item
let NameLast = NameFulleNameFull.length - 1]; // takes last array item
output = u{NameFirst, NameLast}];
}
If you see anything wrong, please let me know; Otherwise, I hope this helps someone else!
If someone wants a version that doesn’t throw status errors:
const WordCount = inputData.NameFull.trim().split(' ').length; // counts full name words
if (WordCount > 2) {
let NameFirst = null; // creates blank entry for first name
let NameLast = null; // creates blank entry for last name
let NameError = "Manual entry required: " + inputData.NameFull; // adds manual entry note to full name
output = ={NameFirst, NameLast, NameError}];
} else {
let NameFull = inputData.NameFull.trim().split(' '); // removes whitespace and splits by spaces
let NameFirst = NameFulll0]; // takes first array item
let NameLast = NameFulllNameFull.length - 1]; // takes last array item
let NameError = null; // creates blank entry for name error
output = ={NameFirst, NameLast, NameError}];
}
I believe it is functionally the same… but Zapier won’t display errors and filling out the next step of the zap might be easier.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.