<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Send Email with Generated PDF as attachment from Trigger &#8211; before Winter 16	</title>
	<atom:link href="https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/</link>
	<description>AI, Salesforce, ServiceNow &#38; Enterprise Tech Guides</description>
	<lastBuildDate>Thu, 27 Jan 2022 20:49:36 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>
		By: Kyle Schwartz		</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-22780</link>

		<dc:creator><![CDATA[Kyle Schwartz]]></dc:creator>
		<pubDate>Thu, 27 Jan 2022 20:49:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.jitendrazaa.com/blog/?p=3851#comment-22780</guid>

					<description><![CDATA[Very helpful Salesforce insights!]]></description>
			<content:encoded><![CDATA[<p>Very helpful Salesforce insights!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: yeswanth		</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-4489</link>

		<dc:creator><![CDATA[yeswanth]]></dc:creator>
		<pubDate>Tue, 26 Jun 2018 12:17:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.jitendrazaa.com/blog/?p=3851#comment-4489</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-2272&quot;&gt;Ricky Hewitt&lt;/a&gt;.

hi ricky i need to implement using Email service i mean attach a pdf file in email and  send email to salesforce then it should create a record in salesforce please send me one example for this]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-2272">Ricky Hewitt</a>.</p>
<p>hi ricky i need to implement using Email service i mean attach a pdf file in email and  send email to salesforce then it should create a record in salesforce please send me one example for this</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nagesh Meesala		</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3779</link>

		<dc:creator><![CDATA[Nagesh Meesala]]></dc:creator>
		<pubDate>Wed, 16 Aug 2017 20:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.jitendrazaa.com/blog/?p=3851#comment-3779</guid>

					<description><![CDATA[Hi Jitendra, I really appreciate your hard work and your motive to share your knowledge. I ran into a situation where a Batch Job is invoking a trigger and this trigger is calling a future method. So it threw an error. In order to avoid this problem, I added a if condition to call Non future method from Trigger in Batch context. So far good. But This Non Future method uses getpdfcontent() method and since a trigger is involved, it threw an exception. So what is the solution in my case.]]></description>
			<content:encoded><![CDATA[<p>Hi Jitendra, I really appreciate your hard work and your motive to share your knowledge. I ran into a situation where a Batch Job is invoking a trigger and this trigger is calling a future method. So it threw an error. In order to avoid this problem, I added a if condition to call Non future method from Trigger in Batch context. So far good. But This Non Future method uses getpdfcontent() method and since a trigger is involved, it threw an exception. So what is the solution in my case.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Naga M		</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3632</link>

		<dc:creator><![CDATA[Naga M]]></dc:creator>
		<pubDate>Mon, 24 Apr 2017 12:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.jitendrazaa.com/blog/?p=3851#comment-3632</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-2737&quot;&gt;SfdcPro&lt;/a&gt;.

Hi Sfdcpro,
Please share the code if you for this implementation]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-2737">SfdcPro</a>.</p>
<p>Hi Sfdcpro,<br />
Please share the code if you for this implementation</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Naga M		</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3631</link>

		<dc:creator><![CDATA[Naga M]]></dc:creator>
		<pubDate>Mon, 24 Apr 2017 12:52:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.jitendrazaa.com/blog/?p=3851#comment-3631</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-2737&quot;&gt;SfdcPro&lt;/a&gt;.

Hi SFDC Pro,
I need to implement the same scenario can you guide me if you know.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-2737">SfdcPro</a>.</p>
<p>Hi SFDC Pro,<br />
I need to implement the same scenario can you guide me if you know.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jitendra Zaa		</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3601</link>

		<dc:creator><![CDATA[Jitendra Zaa]]></dc:creator>
		<pubDate>Wed, 29 Mar 2017 14:08:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.jitendrazaa.com/blog/?p=3851#comment-3601</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3600&quot;&gt;Gourav verma&lt;/a&gt;.

Unfortunately Lex component doesn&#039;t support it yet. I don&#039;t think any library would work as well because of locker service]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3600">Gourav verma</a>.</p>
<p>Unfortunately Lex component doesn&#8217;t support it yet. I don&#8217;t think any library would work as well because of locker service</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Gourav verma		</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3600</link>

		<dc:creator><![CDATA[Gourav verma]]></dc:creator>
		<pubDate>Wed, 29 Mar 2017 13:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.jitendrazaa.com/blog/?p=3851#comment-3600</guid>

					<description><![CDATA[Hi,

Is there any way to download lightning component as pdf? Or you can say that I want to achieve above process in lightning? any thing will be helpful.

Thanks
Gourav Vema]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>Is there any way to download lightning component as pdf? Or you can say that I want to achieve above process in lightning? any thing will be helpful.</p>
<p>Thanks<br />
Gourav Vema</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nisha		</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3455</link>

		<dc:creator><![CDATA[Nisha]]></dc:creator>
		<pubDate>Thu, 22 Sep 2016 19:57:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.jitendrazaa.com/blog/?p=3851#comment-3455</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3452&quot;&gt;Jitendra Zaa&lt;/a&gt;.

Hi Jitendra, Thanks for your reply! 
I was able to figure out an issue in my extension class which was causing the context of the record to get lost. After correcting that code the PDF is now getting generated as expected. 
So currently I am calling the SendPDF method (which in turn calling getcontentAsPdf method) mentioned earlier from VF page. 
Just to make sure that the solution will work when the critical updates are forced on by salesforce, I activated the relevant Critical update and tested the functionality on sandbox (which is on winter 17). To my surprise it is still working correctly, I increased the log level just to check if if it is causing an additional callout but the callout number used is still 0 in the log. Am I missing something here? Isn&#039;t it is expected to fail if called from a normal method? 
Sorry if I am asking very basic question but I am new to Salesforce Development and just want to make sure that I am doing test in correct way. I do not the functionality to fail after October 17 2016 once the critical update is auto activated by salesforce. Can you please help me clarifying my understanding on this?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3452">Jitendra Zaa</a>.</p>
<p>Hi Jitendra, Thanks for your reply!<br />
I was able to figure out an issue in my extension class which was causing the context of the record to get lost. After correcting that code the PDF is now getting generated as expected.<br />
So currently I am calling the SendPDF method (which in turn calling getcontentAsPdf method) mentioned earlier from VF page.<br />
Just to make sure that the solution will work when the critical updates are forced on by salesforce, I activated the relevant Critical update and tested the functionality on sandbox (which is on winter 17). To my surprise it is still working correctly, I increased the log level just to check if if it is causing an additional callout but the callout number used is still 0 in the log. Am I missing something here? Isn&#8217;t it is expected to fail if called from a normal method?<br />
Sorry if I am asking very basic question but I am new to Salesforce Development and just want to make sure that I am doing test in correct way. I do not the functionality to fail after October 17 2016 once the critical update is auto activated by salesforce. Can you please help me clarifying my understanding on this?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jitendra Zaa		</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3452</link>

		<dc:creator><![CDATA[Jitendra Zaa]]></dc:creator>
		<pubDate>Tue, 20 Sep 2016 10:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.jitendrazaa.com/blog/?p=3851#comment-3452</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3451&quot;&gt;Nisha&lt;/a&gt;.

Try this solution - https://www.jitendrazaa.com/blog/salesforce/send-visualforce-as-an-email-attachment-from-apex-trigger-alternate-design/]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3451">Nisha</a>.</p>
<p>Try this solution &#8211; <a href="https://www.jitendrazaa.com/blog/salesforce/send-visualforce-as-an-email-attachment-from-apex-trigger-alternate-design/" rel="ugc">https://www.jitendrazaa.com/blog/salesforce/send-visualforce-as-an-email-attachment-from-apex-trigger-alternate-design/</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nisha		</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/apex/send-email-with-generated-pdf-as-attachment-from-trigger/#comment-3451</link>

		<dc:creator><![CDATA[Nisha]]></dc:creator>
		<pubDate>Tue, 20 Sep 2016 06:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.jitendrazaa.com/blog/?p=3851#comment-3451</guid>

					<description><![CDATA[Hi,
I am also facing the issue where PDF getting generated from VF page are blank. 
I do not have the corresponding critical update activated to treat getContentAsPDF() Methods as Callouts. 
The method getContentAsPDF() is invoked from a method SendPDF on custom controller class. And this SendPDF method is getting called as an action from a VF page.
Below is the code of this method. After upsert Survey, trigger class gets invoked on Survey object.
   
    public static void SendPDF()
        {
        String AccountId  =  ApexPages.currentPage().getParameters().get(&#039;id&#039;);
        String SurveyId   =  ApexPages.currentPage().getParameters().get(&#039;survey&#039;);
        
        Survey__c[] Survey = [ SELECT Id, Name, Status__c, Send_PDF__c
                               FROM   Survey__c
                               WHERE  Id  = :SurveyId LIMIT 1 ];

       if (Survey[0].Status__c.equals(&#039;Complete&#039;)  &#038;&#038; 
           (Survey[0].Send_PDF__c == null &#124;&#124; ! Survey[0].Send_PDF__c.equals(&#039;Sent&#039;)))
           {
           PageReference pdfReport  =  Page.SurveyPg;
               
           pdfReport.getParameters().put(&#039;id&#039;,     AccountId);
           pdfReport.getParameters().put(&#039;survey&#039;, SurveyId );
           //System.debug(pdfReport);

           Blob    PDFBlob  =  pdfReport.getcontentAsPdf();
           String  PDFName  =  &#039;Survey&#039;  +  Survey[0].Name  +  &#039;.pdf&#039;;

           Attachment attachment  =  new Attachment();
           attachment.Body        =  PDFBlob;
           attachment.Name        =  PDFName;
           attachment.ParentId    =  SurveyId;
           insert attachment;
            
           Survey[0].Send_PDF__c     =  &#039;Sent&#039;;
           upsert Survey;
        }
}

We are not sending the PDF as email but instead attaching it to the survey record.
I am not directly calling the method from trigger and also do not have the critical update activated but still facing the issue.
Is there something else I need to do to make sure that getContentAsPDF() works correctly?]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
I am also facing the issue where PDF getting generated from VF page are blank.<br />
I do not have the corresponding critical update activated to treat getContentAsPDF() Methods as Callouts.<br />
The method getContentAsPDF() is invoked from a method SendPDF on custom controller class. And this SendPDF method is getting called as an action from a VF page.<br />
Below is the code of this method. After upsert Survey, trigger class gets invoked on Survey object.</p>
<p>    public static void SendPDF()<br />
        {<br />
        String AccountId  =  ApexPages.currentPage().getParameters().get(&#8216;id&#8217;);<br />
        String SurveyId   =  ApexPages.currentPage().getParameters().get(&#8216;survey&#8217;);</p>
<p>        Survey__c[] Survey = [ SELECT Id, Name, Status__c, Send_PDF__c<br />
                               FROM   Survey__c<br />
                               WHERE  Id  = :SurveyId LIMIT 1 ];</p>
<p>       if (Survey[0].Status__c.equals(&#8216;Complete&#8217;)  &amp;&amp;<br />
           (Survey[0].Send_PDF__c == null || ! Survey[0].Send_PDF__c.equals(&#8216;Sent&#8217;)))<br />
           {<br />
           PageReference pdfReport  =  Page.SurveyPg;</p>
<p>           pdfReport.getParameters().put(&#8216;id&#8217;,     AccountId);<br />
           pdfReport.getParameters().put(&#8216;survey&#8217;, SurveyId );<br />
           //System.debug(pdfReport);</p>
<p>           Blob    PDFBlob  =  pdfReport.getcontentAsPdf();<br />
           String  PDFName  =  &#8216;Survey&#8217;  +  Survey[0].Name  +  &#8216;.pdf&#8217;;</p>
<p>           Attachment attachment  =  new Attachment();<br />
           attachment.Body        =  PDFBlob;<br />
           attachment.Name        =  PDFName;<br />
           attachment.ParentId    =  SurveyId;<br />
           insert attachment;</p>
<p>           Survey[0].Send_PDF__c     =  &#8216;Sent&#8217;;<br />
           upsert Survey;<br />
        }<br />
}</p>
<p>We are not sending the PDF as email but instead attaching it to the survey record.<br />
I am not directly calling the method from trigger and also do not have the critical update activated but still facing the issue.<br />
Is there something else I need to do to make sure that getContentAsPDF() works correctly?</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: www.jitendrazaa.com @ 2026-07-16 20:02:24 by W3 Total Cache
-->