Skip to main content
The PersonNameFormatter class, located is designed to format the names of person that exists in the database or a name that we specify. This class contains the following methods.

Primary methods

Additional methods

GetFormalName method is an extension method used to get the formal name of a person. It is used as an extension to the Person and PersonRow data types, and depending on circumstances is optionally used as a static method. Because user SAL0 is associated with the country Norway, and Norway does not use a title as part of the formal name, Kent’s title of Dr and Mr. are both are ignored in output.
A name format is determined by the AddressFormat ExtraFlags property. When set, the title is added to the name. However, the people with ID 59 and 60 are Norwegian, and therefore the AddressFormat in that case specifies that that title should not appear with the name. To help clarify, the example below changes the person’s country of origin, and then performs the same logic.
With the person’s country of origin changed to Germany, now the Mr. prefix is output in front of the name and the Dr title at the end of the name separated by a new line character. When assigned to the text property of a label control, the Dr title appears on a new line after the name. GetFullName has several overloads to format a person’s fullname according to a specified style, or according to the style stored in user preferences cache. If the user preference cache is not present, the preferences are retrieved from the database and then stored in cache for subsequent requests. The following example demonstrates how to use both extension methods and the PersonNameFormatter on a Person and PersonRow.

Conclusion

Using PersonNameFormatter is useful when working with Person and PersonRow, and makes it easy to get targeting information without having to roll your own name formatter.