Create a Dynamic Detail Page Button For Any sObject using Meta Data
Core to the Salesforce infrastructure, Metadata is what makes the magic happen!
Metadata is a lightweight language based on XML. In Salesforce, metadata represents the structure of salesforce.com and Force.com development elements.
Basically, they are the core components or features that relate to the structure of objects and their fields, configurations, logic, code, and page layouts which build your look, feel, and the information architecture of your Salesforce Org. Instead of the traditional development approach, you can import metadata into your Salesforce Org and modify it in the product interface. This is super fast and immediately available through any web browser and there are no downsides to it
Where can you use it?
The change applies to Lightning Experience and Salesforce Classic in Essentials, Professional, Enterprise, Performance, Unlimited, and Developer editions.|
Steps to Dynamic Detail Page Button for any sObject:
Enter the name of the Button.
Select the sObject which you want to Create Button.
Hit the button “Create custom Button Link”
A button with the label “Save” will be created in the Account Object.
Output:-
Step 1: To do this, let's start off with a super simple controller. Create Apex class
“CreateCustomButtonLink”
Step 2: Create another apex class “MetadataService”
Step 3: Create Visualforce Page
Conclusion
This simple yet effective method will help you create a dynamic detail page button for the sObject of your choice using Metadata. Try it out and if you come up with any queries regarding this, do reach out!