In Salesforce we don’t have an option to rename an Aura component. There are times when we want to rename our Aura component to something more appropriate to the functionality, then we have to create a new Aura component and copy the code to the new component and delete the old one. Isn’t that too much time taking ?
Here is a hack on how you can rename an Aura component. Before I gave you the solution, let me explain you how Salesforce stores all Aura component details.
In salesforce, there is a standard system object “AuraDefinitionBundle” which stores details about component, application, event, interface, or a tokens collection. To know more the AuraDefinitionBundle Metadata, refer to the link – https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_auradefinitionbundle.htm.
When we create a new Aura component, a record gets created in “AuraDefinitionBundle” object with information like Id, developer name, namespace (if any), created date, created by etc.
To rename an Aura component, you can update the record in AuraDefinitionBundle table. For that, go to developer console and write a query on AuraDefinitionBundle in QueryEditor tab. From the list, rename the DeveloperName and click on Save Rows button available at the bottom.
Select Id,DeveloperName FROM AuraDefinitionBundle
This will rename the aura component. Make sure, you update all the reference of this component with the new name. Also, if you try updating the AuraDefinitionBundle object using apex or from Anonymous window, then it will throw error as update is not allowed on this object.
I hope this will be really helpful and time saver for you.
Leave a Reply