Can any one tell me how to schedule the exporting of salesforce report in csv format -
I have a sales force report and what do I want to do is schedule this report in CSV format on a daily basis so that Users match with this attachment.
You can schedule a report using the following code
Global Class Exporter implements CSV system. Schedulable {Global Zero Execution (Scheduled Consultancy SC) {List & lt; Merchandise § & gt; Click here = [ID, name, date created, last modified date from merchandise_cc limit] 10]; String header = 'record id, name, date created, modified date \ n'; String finalstr = header; (Merchandisex a: access) {string recordString = a.id + ',' + a.Name + ',' + a.CreatedDate + ',' + a.LastModifiedDate + '\ n'; Finalist = Finalist + RecordString; } Messaging Email File Attachment csvAttc = New Messaging EmailFileAttachment (); Blob csvBlob = Blob.valueOf (finalstr); String csvname = 'Invoice.csv'; CsvAttc.setFileName (csvname); CsvAttc.setBody (csvBlob); Messaging.Synlemail Message Email = New Messaging. Single email message (); String [] toadress = new list & lt; String & gt; {'Test@salesforce.com'}; String subject = 'merchandise report csv'; Email.setSubject (subject); Email.setToAddresses (toAddresses); Email.setPlainTextBody ('Merchandise report is attached here.'); Email.setFileAttachments (New Messaging. Email File Attachment [] {csvAttc}); Messaging SendEmailResult [] r = Messaging .Andmail (new messaging, single email message [] {e-mail}); }}
Comments
Post a Comment