Split Name Field in 2

Is it possible to split the Name in the Name field into First Name, Last Name? If not I will add two extra Custom Fields.

If I do that are there any ramifications in having the Name field blank (or even deleting the Name field altogether)?

Where do you need to use the split values?
A quick script could seperate on first space or other pattern.

I want to use the first name for kitchen/coffee order tickets. We have a lot of regular customers so when they ‘tag’ in their name will show on the ticket.

At first create script.
image

function split(name) {
var str = name;
var res = str.split(" ");
return res[0]
}

Then paste code below to ticket template where you want.
{CALL:splitd.split(’{ENTITY NAME}’)}

If your customer name is “salim arda kose”. will write only “salim”

image

image

if you want to write “Arda” use this script

function split(name) {
var str = name;
var res = str.split(" ");
return res[1]
}

or for write “köse” use this

function split(name) {
var str = name;
var res = str.split(" ");
return res[2]
}

only change 0,1,2, …
.

Awesome, thanks for that, I’ll test it out tomorrow.
Cheers :+1:

[='{ENTITY NAME}'.replace(/ (.*)/g,"")]

3 Likes

That is more easy. Great.

ilyas YILDIZHAN

[='{ENTITY NAME}'.replace(/ (.*)/g,"")] ilyas

[='{ENTITY NAME}'.replace(/(.*) /g,"")] YILDIZHAN

[='{ENTITY NAME}'.replace(/ (.*)/g,"")] [='{ENTITY NAME}'.replace(/(.*) /g,"")] ilyas YILDIZHAN

3 Likes

Thanks Ilyas, that worked a treat! :+1::+1:

I had to use this though:
[='{ENTITY NAME:Customers}'.replace(/ (.*)/g,"")]

1 Like