I need help with creating apex codes for a scheduler to save an image of my company's dashboard once everyday into the Salesforce document folder.

From This post here I understand you can get an image of the Salesforce Dashboard but I still do not know how to use the apex class to save that image into the Salesforce Document Folder and also how to schedule that time that the apex program is suppose to save the image.

Can anyone help me create an apex class code that can:

  • schedule a certain time to take an image of the Salesforce Dashboard and save the image into the Salesforce document folder?
  • Do you need to save a specific image that is part of your dashboard? Or do you want to save the entire dashboard as you see it in your browser as an image?
    – Kasper
    Apr 6, 2017 at 8:53
  • i want to save the entire dashboard as an image
    – Luke Au
    Apr 6, 2017 at 9:34
  • I have no clue if this would work but you may be able to add your dashboard to a visualforce page, and then use apex to regularly turn the page into a pdf. You could than save the pdf in the document folder.
    – Kasper
    Apr 6, 2017 at 10:03

1 Answer 1


When you have the URL, its easy to convert it into base64.

    String base64Data = '';
    HttpRequest req = new HttpRequest();
    Http http = new Http();
    HttpResponse res = http.send(req);
    Blob image = res.getBodyAsBlob();
    base64Data =  EncodingUtil.base64Encode(image);

Once you have the base64 data, you will just have to insert into an Document record you want to create.

Document doc = new Document();
doc.Name = 'SF Dashboard Image.jpeg';
doc.body = EncodingUtil.base64Decode(base64Data);
doc.folderId = '00l900000027wOx'; //your folder id

insert doc;

Now to the scheduling part, you can write the above logic in a batch class and schedule the batch class to run everyday.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.