Loading

Change the API name of a field

Publiceringsdatum: Jan 27, 2025
Beskrivning

It is recommended not to change the API name of a field unless it's really necessary since they are referenced in the metadata ( i.e Apex Classes, Triggers, Visualforce Pages, Visualforce Components etc).

The changing of API Name without removing references can result in errors being thrown as the operation will be unsupported.

 

Lösning

You need to consider the following implications when changing the API name.

1. Remove References: Ensure that the field is not being referenced in any metadata components such as Apex Classes, Triggers, Visualforce Pages, or Visualforce Components. You will need to remove these references before proceeding.
2. Update Metadata: After removing the references, update the components to refer to the new API name of the field.
3. Webservice Callouts: If there are any webservice callouts via Apex Code, remove the usage and update the API names in the code accordingly.

    There are no suggested automation tools which will change all the API names used in metadata components. However, you can use tools like Salesforce Extension for VS Code which enables you to search for the references in the metadata after it has been retrieved from the Org. After doing the same, you can change the references to the old API Name of the Object/Fields.

    Ytterligare resurser

    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-artikelnummer

    000382423

     
    Laddar
    Salesforce Help | Article