Logic to use the preferred name if it exists or use the first name if the preferred name does not exist

We have run into a situation where in UKG some users have a preferred name while some do not. I am trying to figure out the logic to use the preferred name if it exists or use the first name if the preferred name does not exist.

I am looking specifically at the display name in this case.

Here is what I was starting with:

1st condition
WHEN
Person.PreferredName == Person.PreferredName.IsNullOrEmpty
This does not appear to be valid unless I have either IsInsert && or IsUpdate &&
THEN
Person.LastName + ', ’ + Person.FirstName

2nd Condition
WHEN
Default
THEN
Person.LastName + ‘, ’ + Person.PreferredName

I’m trying to determine the best way to setup the logic, either one statement or several

I appreciate any insight you can provide.

This should do it,
IsUpdate || IsInsert && Person.PreferredName == Person.PreferredName.IsNullOrEmpty

Think I’m going to be using this in our environment as well.
Take care,

The Person.PreferredName field is smart enough to use a prefered name if there is a value, if there is no preferred name, it will fall back to using the Person.FirstName field.

You don’t need any special logic or expression to meet this requirement.

This logic is already built into the Person.PreferredName field.