Welcome to my blog

I have been working with Salesforce for quite a while, so don’t hesitate to contact me if you have any questions or want some advice.

s f

Follow Us

How to export Salesforce Object field name into CSV file?

 . Adminstrator  . How to export Salesforce Object field name into CSV file?

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’;
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] toAddresses = new list<string> {‘Enter your email address’};
String subject =’Apex Batch Class Name CSV’;
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});

Post a Comment