Let’s be honest—most of us have been using Windows since we were kids. It’s the backbone of the corporate world and feels like the default choice for every computer user. For years, I thought it was the only real option. But what if I told you there isn't just an "alternative" out there, but a genuine upgrade? When people talk about switching to Linux , it can feel overwhelming because there are so many versions. However, I want to talk specifically about Ubuntu .
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});
}
}