---
schema_version: "1"
id: 26961538a43cf8db4c3fb8a08d986a5e16a5e08d8864804638cf46191cc211a0
title: Create an Apex Class for Preference Manager
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/preference_center_apex_class.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.preference_center_apex_class.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 1e2478854e11b9121398bcb8112496e2750d6815ccd3303e8095f41affe1abb3
description: Use Preference Builder along with the Pref_center Apex namespace to create forms with advanced customizations. The Pref_center Apex namespace represents the former name of the Preference Manager feature.
products:
  - Security
  - Cross Cloud
release: "264"
---
# Create an Apex Class for Preference Manager

Use Preference Builder along with the Pref\_center Apex namespace to create forms with advanced customizations. The Pref\_center Apex namespace represents the former name of the Preference Manager feature.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience and Salesforce Classic in <strong>Developer</strong>, <strong>Enterprise</strong>, <strong>Performance</strong>, and <strong>Unlimited</strong> Editions</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d4815e46">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d4815e46 ">To use Preference Manager:</td>
            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d4815e46 ">ManagePreferenceManager</td>
          </tr>
        </tbody>
      </table>

When you create your form in Preference Builder, the details, like the names and configuration of sections that you included, are saved as metadata. When a user opens the preference form, your custom Apex class retrieves and sets that metadata to configure the form on your site. Then when the user completes and submits the form, the Apex class creates or updates the submitted data into the relevant Salesforce consent objects.

Before you configure the preference form, create your Apex class to control how data passed through the form is managed.

1. From Setup, in the Quick Find box, enter Custom Code, select **Apex Classes**, and then click **New**.
2. In the Apex Class text box, copy and paste this code, and replace \[YOUR APEX CLASS NAME\] with the name that you want for your Apex class:

![Example](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-data_protection_and_privacy-264-0-0-production-enus/27d1bf87-a47b-491a-8339-f53ef6540aec/images/icon_example.png)

Example

```html
public without sharing class [YOUR APEX CLASS NAME] implements pref_center.PreferenceCenterApexHandler {
public void submit(pref_center.SubmitParameters submitParams, pref_center.SubmitFormData formData, pref_center.ValidationResult validationResult) {

}

public pref_center.LoadFormData load(pref_center.LoadParameters loadParams, pref_center.LoadFormData loadFormData, pref_center.ValidationResult validationResult) {
return loadFormData;
}
}
```

For more information about Apex classes, see the [Apex Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_understanding.htm) and the [Create an Apex Class module](https://trailhead.salesforce.com/en/content/learn/projects/quickstart-apex/quickstart-apex-1) in Trailhead.