Loading

Change the API name of a field

Julkaisupäivä: Jun 19, 2026
Kuvaus

Changing the API name of a custom field in Salesforce is possible but carries significant risk. It is strongly recommended not to change the API name of a field unless absolutely necessary. Field API names are referenced across many types of metadata in a Salesforce org, including Apex Classes, Apex Triggers, Visualforce Pages, Visualforce Components, and web service callouts in Apex code. Renaming a field API name without first removing all existing references causes errors and the change may be unsupported.
Real-World Example: If a managed package field has the API name vlocity_cmt__DeliveryMethod__c and your custom field is also named DeliveryMethod__c, this creates a conflict. Rename your custom field to something unique like OurDeliveryMethod__c to avoid the conflict.


 

Ratkaisu

Step 1: Identify All References to the Field

Before making any changes, locate every place the existing API name is referenced in your org metadata:

  • Apex Classes
  • Apex Triggers
  • Visualforce Pages
  • Visualforce Components
  • Web service callouts in Apex code

Use the Salesforce Extension for VS Code to retrieve your org metadata and search all occurrences of the old API name.

Step 2: Remove or Update All References

Remove or update every reference to the old API name before proceeding with the rename. Failing to do this causes runtime errors after the rename.

Step 3: Rename the Field API Name in Salesforce Setup

  1. Click the Setup gear icon and select Setup.
  2. Navigate to Object Manager and select the relevant object.
  3. Click Fields & Relationships and search for the custom field.
  4. Click the dropdown arrow next to the field and select Edit.
  5. Update the field name to the new API name and click Save.

Step 4: Update All Metadata to Use the New API Name

After the rename, update all Apex Classes, Triggers, and Visualforce components to reference the new API name, then redeploy the updated metadata to your org.

Step 5: Update Web Service Callouts (If Applicable)

If any external integrations or Apex-based web service callouts reference the old API name, update those references to the new API name and redeploy.

Lisäresurssit

As an example, if you encounter conflicts with managed package fields, you may need to rename the custom field API to avoid such issues. For example, if a managed package field has the API name "vlocity_cmt__DeliveryMethod__c", you should rename your custom field from "DeliveryMethod__c" to something unique like "OurDeliveryMethod__c".

Steps to Rename Field API Names:

1. Click the Setup gear icon, then select Setup.
2. Select Object Manager, then select the relevant object.
3. In Fields & Relationships, search for the custom field.
4. Click the dropdown arrow next to the field, select Edit, and change the field name.
5. Click Save.

 

Knowledge-artikkelin numero

000382423

 
Ladataan
Salesforce Help | Article