How to export Salesforce Object field name into CSV file?
Learn How to Export Salesforce Object Field Name Into CSV File?
Please run below script through developer console you will receive a email with list of field for that object.
Note: Please replace with your email address and object based on your need.
Map<String, Schema.SObjectField> fMap = Schema.getGlobalDescribe().get('Account').getDescribe().Fields.getMap(); list<string> selectFields = new list<string>(); string excelHeader = ‘ApexName\n’; if (fMap != null){ for (Schema.SObjectField ft : fMap.values()){ Schema.DescribeFieldResult fd = ft.getDescribe(); excelHeader += fd.getName() +’\n’; } } Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment(); blob csvBlob = Blob.valueOf(excelHeader); string csvname= ‘ApexClassBatchName.csv’; csvAttc.setFileName(csvname); csvAttc.setBody(csvBlob); Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage(); String[] toAddresses = new list<string> {‘Enter your email address’}; String subject =’Apex Batch Class Name CSV’; email.setSubject(subject); email.setToAddresses( toAddresses ); email.setPlainTextBody(‘Apex Batch Class Name CSV ‘); email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc}); Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
0 Comments