Custom Metadata Types vs Custom Settings vs Custom Labels 💬 In plain words: Three lookalikes: Custom Metadata = configuration that DEPLOYS with your code (best for app settings). Custom Settings = org/user-specific values, changeable at runtime (hierarchy type is great for bypass switches). Custom Labels = translatable text for the UI. 📌 Example: API endpoint URLs per environment → Custom Metadata (deploys with code, sandbox vs prod values). A 'Bypass_Automation__c' checkbox an admin flips during data load → hierarchy Custom Setting. The word 'Submit' translated to Hindi → Custom Label. 🎬 Real-Life Example: The Fee Table Trapped Inside Code Skyline charges a different delivery fee per city. Apex needs those rates on every booking. The Old/Bad Way: if (city == 'Delhi') fee = 50. Else if (city == 'Mumbai') fee = 65. … Every rate change is a code change, a test run, and a deployment. Why this is bad: Business data is trappe...
Below is sample code to to get all object and their fields in CSV using apex in salesforce. In this sample code we are getting objects using namespace and making CSV file.
pubLIC class ObjectFieldsinReport{
public void makecsvwithobjectandfield(){
map<string, SObjectType> objs = schema.getGlobalDescribe();
string header = 'Object Name, Field, Label \n';
string finalstr = header ;
for(string key: objs.keySet()){
//if condtion to handle namespace objects
//remove this key.startsWithIgnoreCase('Your objects namespace') if you want to use all objects
if(key.startsWithIgnoreCase('Your objects namespace') && key.endsWithIgnoreCase('__c')){
map<string, string> fieldList = new map<string, string>();
if(key != null){
map<string,SObjectField> fList = schema.getGlobalDescribe().get(key).getDescribe().fields.getMap();
for(string str: fList.keySet()){
fieldList.put(str, fList.get(str).getDescribe().getLabel());
}
string recordString;
for(string objmap : fieldList.keyset()){
recordString = key+','+objmap+','+fieldList.get(objmap)+'\n';
finalstr = finalstr +recordString;
}
finalstr = finalstr +recordString+'\n';
}else{
return;
}
}
}
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(finalstr);
string csvname= 'Report.csv';
csvAttc.setFileName(csvname);
csvAttc.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] toAddresses = new list<string> {'email address'};
String subject ='object CSV';
email.setSubject(subject);
email.setToAddresses( toAddresses );
email.setPlainTextBody('body Text');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
}
}