Tags

, , ,

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:

NamesOrderWrong01

Here you can try it:
http://training.directsmile.de/blogstuff/11001

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]]
NamesOrderWrong02

Click the plus icon to add a condition.
NamesOrderWrong03

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

…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’:
NamesOrderWrong05

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

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

and enter a space as static text:
NamesOrderWrong08

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

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

That’s all :-) Please try it here:
http://training.directsmile.de/blogstuff/11001

Advertisements