Problem: System.VisualforceException: Getting content from within triggers is currently not supported.
Description: This Visualforce exception occurs when we use getContent method in the trigger of sobject.
Here is the code for which we got this exception:
Trigger code:
trigger updateStatus on sobject (before update) {
List List = new List();
for(sobject term : Trigger.new){
sobject oldOpp = Trigger.oldMap.get(term.Id);
if(term.Payment_Status__c ==’Paid’){
Messaging.SingleEmailMessage emailTobeSent = new Messaging.SingleEmailMessage();
PageReference pdf = Page.templateCOI; //Replace attachmentPDF with the page you have rendered as PDF
pdf.getParameters().put(‘Id’,term.Id);
pdf.setRedirect(true);
Attachment attach = new Attachment();
Blob b […]