, , ,

Today I had an interesting question from a customer and I want to share the easy solution with you. If you use only one database column for first name and last name, you probably want the data input like this: first name last name

But maybe you got a database which is not perfect or maybe you created a personalized url with only one text input field and in the end, you might have records that look like this: last name, first name

There is an easy solution how to display first name last name, even if it is (sometimes) the other way around in the database. Let’s imagine you display a DirectSmile Set on a purl. The usual assignment would be the database column [[Name]]. You can create a rule that checks if there is a comma in the text. If yes, the Set should show the text after the comma, a space and the text before the comma. It looks like this:


Here you can try it:

Detailed description
The functions ‘Last part’ and ‘First part’ return the last/first part of a given string after splitting it with the specified split string. Open the assignment window (e.g. of a Set or a text variable) to use these functions.

Select the database column [[Name]]

Click the plus icon to add a condition.

Create the condition: If the database column [[Name]] contains a comma…

…then we need the last part after the comma, a space and the first part before the comma. At first we select the function ‘Last part’:

The input is the database column [[Name]] and the Splitter is a comma:

Click the plus icon on the right to add another field:

and enter a space as static text:

Click the plus icon on the right again to add another field and select the function ‘First part’:

The input is again the column [[Name]] and the Splitter is the comma:

That’s all :-) Please try it here: