1

I want to create a PDF on a custom object, and have the ability to save it in a related object. I know I can save it in "Notes & attachment", but I'm wondering if it's possible to create a custom object similar to the "Quote PDFs" object in Quote functionality, and save the PDF there

1

As per my knowledge, You can only upload a file into "Documents" or in "Notes & Attachment". But what you can do, you can create a custom object and in this object, you can create a field (text) to store the ID of Document or Attachment uploaded. After doing so you can create another formula field to construct download link for this uploaded file.

1
  • Thanks @doga, can I change the attachment name to be a link? – Itay B May 23 '13 at 15:01
1

We do something similar to Doga's answer, but use the newer chatter objects. You're going to want this kind of stuff accessible in mobile app, etc, and salesforce definitely is heading strongly in that direction.

This example is generating a pdf using a VF page, then snapping it and attaching it to a custom object.

The chatter object also lets you relate an attachment to multiple items like your question states.

public PageReference CloseOut(){

    Billing_Documents__c BD = new Billing_Documents__c();        
    bd.recordtypeid = [select id from recordtype where name = 'Deal Ticket'].id;        
    insert bd;
    bd=[select id, name from Billing_Documents__c where id=:bd.id];
    feeditem a = new feeditem();

    PageReference PR = Page.DealTicket;
    PR.getparameters().put('contract', SelectedContract);
    PR.getparameters().put('DT', bd.name);
    //create a deal ticket and save the result page as a pdf;
    blob pdf = PR.getcontentasPDF();
    a.ContentData = pdf;
    a.ContentFileName = 'DealTicket'+ BD.name+'--'+system.now()+'.pdf';
    a.parentid = bd.id;
    insert a;
    closePositions(bd.id);
    PageReference BDpage = new ApexPages.StandardController(bd).view();
    return BDPage;
}
1
  • What I want to achieve is the ability to save the PDF into a custom object, and use the attach file as an email attachment. (for some reason, files saved under "Notes & Attachments" are not available to be attached to email attachments). I didn't understand the linkage to the chatter objects... – Itay B May 26 '13 at 13:55

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.