Create custom fields for a customer

Create the custom field

To create a custom field for a customer, use the Fluent API and perform the following:

  1. Get the Type of the Customer.
  2. Create a new custom field.
  3. Save the changes.

Use the following code sample:

Set the value of the custom field

To set the value of the field perform the following:

  1. Get the orders manager.
    Get an instance of the OrdersManager object.
  2. Get the customer.
    Get an instance of the specified customer. For more information, see For developers: Query customers.
  3. Get the custom fields for the customer.
    To get the available custom fields for the customer, call the GetProperties static method of the TypeDescriptor class and pass the instance of the customer as an argument.
  4. Get the custom field.
    Get the PropertyDescriptor instance for the specified custom field.
  5. Check whether the field exists.
    If the field exists you can set it. Otherwise, skip the next steps.
  6. Set the value of the custom field.
    To set the value of the custom field, call the SetValue extension method of the Customer instance. Pass the name of the field and its value.

    NOTE: To use the SetValue method you must add an using clause for the Telerik.Sitefinity.Model namespace.

  7. Save the changes.
    Save the changes to the manager.

Use the following code sample:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?