Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
global class VFChart_Server{
public Opportunity opportunity {get;set;}
public VFChart_Server(ApexPages.standardController std){
public List<PieWedgeData> getPieData() {
List<PieWedgeData> data = new List<PieWedgeData>();
data.add(new PieWedgeData('Jan', 30));
data.add(new PieWedgeData('Feb', 15));
data.add(new PieWedgeData('Mar', 10));
data.add(new PieWedgeData('Apr', 20));
data.add(new PieWedgeData('May', 20));
data.add(new PieWedgeData('Jun', 5));
return data;
// Wrapper class
public class PieWedgeData {
public String name { get; set; }
public Integer data { get; set; }
public PieWedgeData(String name, Integer data) { = name; = data;
global static void saveChartAsAttachment(String oppId,String attachmentBody){
system.debug('@@@saveChartAsAttachment oppId ='+ oppId);
List<Attachment> listAttachment =[Select Name,Id,Body from Attachment Where ParentId=:oppId];
Attachment att;
att =listAttachment[0];
att.Body = EncodingUtil.base64Decode(attachmentBody);
update att;
att = new Attachment();
att.Body = EncodingUtil.base64Decode(attachmentBody);
insert att;
Copy link

shoaebk commented May 22, 2017

Thanks for sharing this code. It's very helpful.
Can you please guide me how to use the saved attachment via apex and render it in Visualforce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment