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
Cloud Advisory GroupCloud Advisory Group 

VF Email Wrapper Class Woes

I am attempting to build a visualforce email template, controller, and component to basically act a a catch all of object records so that we can build any type of email relating to a transaction.

 

We are working with 7 different objects, and we would like to be able to show any records from a sale instance. The way we have accomplished this on other visualforce pages is through wrapper classes, unfortunately the same slighlty modified code does not work for a visualforce email component and controller. The workflow works and sends an email but the subject is gone and there is no body. Below is my code, I have found that if I comment out in the controller everything after line 48 it sends some test variables fine, but as soon as the wrapper classes are actually interacted with the whole thing breaks. There is also apparently no way to debug controllers used in an email's component?

 

Any help you can offer is greatly appreciated.

 

Thank you.

 

EMAIL TEMPLATE

<messaging:emailTemplate subject="Service Receipt" recipientType="Contact" relatedToType="CAG_Transaction__c">
    
    <messaging:htmlEmailBody >
    <c:cagSalesReceipt tId="{!relatedto.id}"/>

    </messaging:htmlEmailBody >
    
</messaging:emailTemplate>

 COMPONENT

<apex:component controller="cag_email_transaction_controller" access="global">
    <apex:attribute name="tid" type="Id" description="Transaction Id" assignTo="{!transid}"/>

  		<apex:repeat value="{!tlist}" var="tt">
  		your transaction id:{!tt.id}
  		</apex:repeat>
  		Your Sale id{!s.id}

</apex:component>

 CONTROLLER

public with sharing class cag_email_transaction_controller {    
  public cag_sale__c s {get;set;}
  public CAG_Transaction__c t {get;set;}
  public string saleid {get;set;}
  public id transid {get;set;}

  public cag_email_transaction_controller() {     
  }
  public class sw{
    public Cag_sale__c si {get;set;}
    public list <spdw> spdws {get;set;}
  }

  public class spdw{
    public CAG_Sale_to_pd_juction__c spdi {get;set;}
    public list <pdw> pdws {get;set;}
  }

  public class pdw{
    public Product_to_Device__c pdi {get;set;}
    public list <dw> dws {get;set;}

  }

  public class dw{
    public Cag_devices__c di {get;set;}
    public list <dgw> dgws {get;set;}
  }

  public class dgw{
    public CAG_Diagnosis__c dgi {get;set;}
  }

  public list <sw> sws {get;set;}

  public list <CAG_Transaction__c> gettlist(){
  	set<id> diagID = new set<id>();
  		for(CAG_Transaction__c ti: [select id from CAG_Transaction__c where id = :transid]){
  			t = [select id, cag_sale__c from CAG_Transaction__c where id = :transid];
  		}
  		s = [select id from cag_sale__c where id = :t.cag_sale__c];
  		list <cag_sale__c> sis =[select id, (select id from CAG_Sale_to_pd_juctions__r), (select CAG_Diagnosis__c from CAG_Sale_to_Diagnosis_Junction__r) from cag_sale__c where id = :t.cag_sale__c];    
	      for (cag_sale__c si : sis){
	        list <CAG_Sale_to_pd_juction__c> spdis = [select id, CAG_Product_to_Device__c from CAG_Sale_to_pd_juction__c where id = :si.CAG_Sale_to_pd_juctions__r];      
	        list<CAG_Sale_to_Diag__c> salediags = [select id,CAG_Diagnosis__c  from CAG_Sale_to_Diag__c where id = :si.CAG_Sale_to_Diagnosis_Junction__r];
	        for(CAG_Sale_to_Diag__c salediag : salediags){
	            diagID.add(salediag.CAG_Diagnosis__c);
	            }      
	        sw addsws = new sw();
	        sws.add(addsws);
	        addsws.si=si;
	        addsws.spdws = new list <spdw>();
	        for (CAG_Sale_to_pd_juction__c spdi : spdis){
	          list <Product_to_Device__c> pdis = [select id, CAG_Devices__c,Membership__r.Membership__c, Membership__r.Duration__c, Membership__r.price__c, upfront__r.upfront__c, Upfront__r.price__c, upfront_addition__c, membership_addition__c, Membership_Subtraction__c, Upfront_Subtraction__c, upfront_price__c, membership_price__c from Product_to_Device__c where id = :spdi.CAG_Product_to_Device__c];
	          spdw addspdws = new spdw();
	          addsws.spdws.add(addspdws);
	          addspdws.spdi = spdi;
	          addspdws.pdws = new list <pdw>();
	          for (Product_to_Device__c pdi : pdis){
	            list<Cag_devices__c> dis = [select id, Device_Type__c, Brand__c, Model__c, Operating_System__c, (select id from cag_diagnoses__r), Password__c, Username__c, no_username__c from Cag_devices__c where id = :pdi.CAG_Devices__c];
	            pdw addpdws = new pdw();
	            addspdws.pdws.add(addpdws);
	            addpdws.pdi = pdi;
	            addpdws.dws = new list <dw>();
	            for (Cag_devices__c di : dis){
	              list <CAG_Diagnosis__c> dgis = [select id, Why_did_the_customer_call_in__c, Main_Picklist__c, Additional_Description__c from CAG_Diagnosis__c where id = : di.cag_diagnoses__r and id in :diagID];
	              dw adddws = new dw();
	              addpdws.dws.add(adddws);
	              adddws.di = di;
	              adddws.dgws = new list <dgw>();
	              for (CAG_Diagnosis__c dgi :dgis){
	                dgw adddgws = new dgw();
	                adddws.dgws.add(adddgws);
	                adddgws.dgi = dgi;
	              }
	            }
	          }
	        }
	      }
      return [select id from CAG_Transaction__c where id = :transid];
  }

}

 

KruthiiiKruthiii
Hi,

Were you able to get through this issue?
I am also facing an issue in fetching the values to component from wrapper class.
Any help is greatly appreciated.

Thanks