+ Start a Discussion

Best way to rename custom object's API name



I've recently discovered that the custom object name 'Site', with the API name 'Site__c' seems now to be used as a native SF object name (presumably since Sites went public).  I use this name in my application and now need to deploy it to another org.  Of course, I'm unable to transfer my custom Site__c object, because SF complains that the name already exists.


I have that name referenced in quite a few Apex classes and VF pages.  What is the most practical to go about resolving this?  I can think of a couple of ways:


Option 1 -- Try reusing the existing 'Site' object

- Temporarily remove all references to Site__c from all Apex and VF page files (How???  This sounds like it would be a pain.)
- Rename the site API name to 'azSite__c' (for example)

- Modify all of the Apex and VF page references to the old name ('Site__c') to reference 'azSite__c'

- Can keep existing Site data

- Temporily removing existing references sounds very painful

Option 2 -- Create and use a new 'Site' object

- Create a new site object with the API name 'azSite__c'
- Modify all of the Apex and VF page references to the old name ('Site__c') to reference 'azSite__c' (can do this by doing a global 'search and replace' on the local files in Eclipse, then saving files to Force.com)

- Simpler to implement than trying to modify existing object
- Lose existing Site data 


Are there other options that I'm overlooking? Can something be done with namespaces to avoid the conflict with the built-in name 'Site'?


Any suggestions would be greatly appreciated.


Thank you in advance!




You would need to use a namespace in this scenario. More information about namespaces can be found here.



Thanks for your reply.  A follow-up question (or two).   The docs for namespaces say:


Salesforce automatically prepends your namespace prefix, followed by two underscores ("__"), to all unique component names in your Salesforce organization. A unique package component is one that requires a name that no other component has within Salesforce, such as custom objects, custom fields, custom links, s-controls, and validation rules. For example, if your namespace prefix is abc and your managed package contains a custom object with the API name, Expense__c, use the API name abc__Expense__c to access this object using the API. The namespace prefix is displayed on all component detail pages.


Is the 'API' referred to here the 'client' API?  For example if I want to expose a Web Service and call it from Java, I'd have to use the namespace prefix in the call.  Or do I somehow have to reference the namespace prefix in the Apex code?  I'm assuming it's the former, because the latter doesn't seem to make much sense--since the namespace would change from org to org as the package gets inistalled in different orgs, I couldn't really reference it in the Apex code.  Or am I missing something?