• Kruthiii
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
I understand we have Trailhead however I am looking for the list of problems that need/ can be practiced for apex in one place. Thanks
i want to display the custom error  message .how to solve the above solution please give any ideas.

Hi all

 

I'm new to SF using apex code.

What's the way to access/join objects and obtain the custom fields?


Contracts
|
Clients
|
Campaigns (Trying to access this object and custom field values from the Contracts object - top down approach)

 

Thanks

Shaun

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];
  }

}

 

hi,

 

Im new to salesforce and im trying out some simple things first.

 

I am having two custom objects :- Employee__c and Department__c

 

Employee__c has a lookup for department__c.

 

What i want to do is  display all the employees associated with a particular department in one single row.(Two columns :- Departments and Employees)

 

 

for eg:- if ther are two departments:-

 

1) Sales 2)HR

 

then the page should look like:

 

Sales(under departments column)  -  xyz, pqr, etc(in employee column)   

 

For that purpose i've the following class:-

 

 

public class EmpList2
{   
   
   public List<Department__c> lstDepartment = new List<Department__c>();
  
    
    public EmpList2(ApexPages.StandardController Ctlr )
    {  
               
           
        lstDepartment = [select name,(Select Name From Employees__r) from department__c];
        system.debug('---lstdept---'+lstDepartment);
                        
    }
   
  
    public List<department__c> getListDpt()
    {
        return lstDepartment;
    }
        

}

 

 

and the following visualforce page ..

 

 

 

<apex:page standardController="Employee__c" extensions="EmpList2">
<apex:form >
<apex:sectionHeader title="Employee List" subtitle="(All Departments)"/>
<apex:pageBlock title="Employees">
<apex:pageblocktable value="{!ListDpt}" var="item1" id="pb">
<apex:column headerValue="Departments">{!item1.name}</apex:column>
<apex:column headerValue="Employees" >
      <c:myComponent record="{!item1.employees__r}"></c:myComponent>
</apex:column>
</apex:pageblocktable>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

also im trying to have my own custom component(myComponent)..i am passing the records recived(i guess that is a list....item1.employees__r)  to a custom component which is as follows :-

 

 

<apex:component >
<apex:attribute name="record" description="Create a link(outputLink)" type="Employee__c[]" ></apex:attribute>
<apex:outputLink value="/someurl">{!record) </apex:outputLink>
</apex:component>

 

when i use this code the output i am getting is 

 

department names under departments column...but i am not getting the employee names under employee column....instead i am getting their ids...but that to inside a sqaure bracket like the one below:

 

 

column 1 : department name         column 2: - [a0190000000c26QAAQ, a0190000000c2A8AAI, a0190000000c2U4AAI],

 

 

 

so please help me find a solution over it...do i need to use a seperate class for a custom component too?

 

if yes..then how am i going to pass the list to the component's controller?

 

 

Thanks in advance.  

 

 

  • January 29, 2010
  • Like
  • 0