Technology has always been a bridge, but today, it feels more like a mirror. With the rapid rise of AI , we are seeing things enter our lives and leave them at a pace we can barely track. To understand where this is going, we first have to understand how technology actually impacts the core of who we are. The Survivalist vs. The Ego Our minds are biologically wired for one thing: survival . We are designed to handle the worst-case scenario, an ancient instinct gifted to us by nature. We consider ourselves conscious decision-makers, but a critical question remains: Who is really making the call?
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});
}
}