function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sarika PatelSarika Patel 

Not able to retrieve Current Quote PDF ID

Hi,

I have a trigger that helps me to generate an email for sending the quote. The only problem is its not able to attache a quote PDF.
Here is the sample code:

  List<Quote> quotes = [Select Id,ContactId,OpportunityId,(Select Id,Name from QuoteDocuments order by LastModifiedDate desc limit 1) from Quote where Primary__c = true and OpportunityId in: oppIdsToProcess];     
       
        for(Opportunity opp : Trigger.new)
        {
            if(opp.Probability == 100)
            {
                string attachId = '';
              
                for(Quote q : quotes)
                {
                    if(q.OpportunityId == opp.Id)
                    {
                    
                        if(q.QuoteDocuments.size()>0)
                       {
                         
                        attachId = q.QuoteDocuments[0].Id;
                        }
                        
                    }
                }


So I am able to go till q.QuoteDocuments.size but since the size is zero, its not able to get the doc_id. Could anyone please help? I am new to this.
ShashankShashank (Salesforce Developers) 
You will have to generate the pdf first. You may find these helpful:
http://corycowgill.blogspot.sg/2012/02/generating-pdf-in-apex-trigger.html
http://stackoverflow.com/questions/12510287/generating-pdf-from-trigger-future-class-in-salesforce