• Jeff_Rogers.ax1383
  • NEWBIE
  • 75 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 10
    Replies

I'm not getting any data to display in my email template when passing the caseId to query the Case_Product_Name and Serial_Number__c fields from the "Problem" object.  I do get data when I hard code the caseId in the getSerials setter.  Keep in mind the case_id__c field is a string data type on the problem object" (its a formula field to make this email template easier to create intead of building a wrapper classs to get the data... the relationship between the objects are amaster-detail from Case to Case Product to Problem).

 

Any help would be greatly appreciated!  Thanks!

 

Email Template:

<messaging:emailTemplate subject="test" recipientType="Contact" relatedToType="Case">
    <messaging:htmlEmailBody >

        <c:Case_Product_Serials paramCaseId="{!relatedTo.Id}"/>          
    
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

 

Component:

<apex:component controller="caseProductSerials" access="global">
    <apex:attribute name="paramCaseId" type="Id" description="Case Id parameter" assignTo="{!caseId}"/>
                <apex:repeat value="{!serials}" var="serial">
                   <apex:outputText value="{!serial.case_product_name__c}" />
                </apex:repeat>
 </apex:component>

 Controller:

public class caseProductSerials {
    
    Public Id caseId {get;set;}
    Public List<Problem__c> serials = new List<Problem__c>();
    
    public caseProductSerials() {
    }
    
    public List<Problem__c> getserials(){
        return [SELECT case_product_name__c, serial_number__c FROM problem__c where case_id__c =: caseId]; //'500Q0000003woSF'];
    }
    
}

 

 

I'm not getting any data to display in my email template when passing the caseId to query the Case_Product_Name and Serial_Number__c fields from the "Problem" object.  I do get data when I hard code the caseId in the getSerials setter.  Keep in mind the case_id__c field is a string data type on the problem object" (its a formula field to make this email template easier to create intead of building a wrapper classs to get the data... the relationship between the objects are amaster-detail from Case to Case Product to Problem).

 

Any help would be greatly appreciated!  Thanks!

 

Email Template:

<messaging:emailTemplate subject="test" recipientType="Contact" relatedToType="Case">
    <messaging:htmlEmailBody >

        <c:Case_Product_Serials paramCaseId="{!relatedTo.Id}"/>          
    
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

 

Component:

<apex:component controller="caseProductSerials" access="global">
    <apex:attribute name="paramCaseId" type="Id" description="Case Id parameter" assignTo="{!caseId}"/>
                <apex:repeat value="{!serials}" var="serial">
                   <apex:outputText value="{!serial.case_product_name__c}" />
                </apex:repeat>
 </apex:component>

 Controller:

public class caseProductSerials {
    
    Public Id caseId {get;set;}
    Public List<Problem__c> serials = new List<Problem__c>();
    
    public caseProductSerials() {
    }
    
    public List<Problem__c> getserials(){
        return [SELECT case_product_name__c, serial_number__c FROM problem__c where case_id__c =: caseId]; //'500Q0000003woSF'];
    }
    
}

 

 

I have 3 different objects that I want to display data from in anemail template: Case -> Case Product -> Problem

 

I want to send the email from the case page and want to display a table of Case Products and associated Problems.

 

Is this possible?  If so, what would be the plan of attack?

 

I would think I'd need a component in the visualforce email template that would display data aggregated via a wrapper class.

 

I'm able to get this to work on a standard visualforce page with a commandlink to initiate a wrapper controller method that compiles the data for me (see the code below), but I don't know how to initiate that action through visualforce within an email template.  Suggestions?

 

Thanks!

 

Visualforce Page  - "TestPage"

<apex:page title="Wrapper Demo" controller="wrapperCON" tabStyle="Case">
    <apex:sectionHeader title="Wrapper Demo"/>
    <apex:form >
    <apex:pageBlock title="Setup">
        <apex:pageBlockButtons location="top">
            <apex:commandLink action="{!buildwrapper}">
                <apex:param name="caseId" value="500Q0000003woSF"/>  
                       <apex:commandbutton value="Demo" />
            </apex:commandLink> 
        </apex:pageBlockButtons>
    </apex:pageBlock>
    <apex:pageBlock >
        <apex:repeat value="{!wrapout}" var="w">
            <hr/>
           <apex:outputText value="{!w.caseProd.name}" /> <br/>
                   <apex:repeat value="{!w.problems}" var="wo">
                       Problems: <apex:outputText value="{!wo.Prob.name}" /> <br/>
                   </apex:repeat>
        </apex:repeat>
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

//APEX CONTROLLER 

public class wrapperCON {
       
    private List<Case_Product__c> tempCaseProd = new List<Case_Product__c>();
    private Map<ID,List<Problem__C>> CaseProdProbMAP = new Map<ID,List<Problem__c>>();
    private Set<ID> CaseProdIds = new Set<ID>();//case product ids to get problems from
    public List<wrapper> wrapout {get; set;}
    //constructor
    public wrapperCON(){
       wrapout = new List<wrapper>();
       
    }    
    //wrapper 1
    class wrapper{
        public Case_Product__c caseProd {get; set;}
        //This is a list of other wrappers that is nested in the first list
        public List<wrapper2> problems {get; set;}
        public wrapper(){
            if(caseProd==null){caseProd = new Case_Product__c();}//initialize the case product holder
            if(problems==null){problems = new List<wrapper2>();}//initialize the wrapper listholder
        }
    }
    //wrapper 2 - the sub-wrapper
    class wrapper2{
        public Problem__c Prob {get; set;}
        //public List<Product2> oppprods {get; set;}
        /*public wrapper2(){
            if(Opp==null){Opp = new Opportunity();}//initialize the Opportunity holder
            if(oppprods==null){oppprods = new List<Product2>();}//initialize the product2 holder
        }*/
    }
    
    //This is the "Run Demo" Button on our VF page
    public PageReference buildwrapper() {
        String caseId = ApexPages.currentPage().getParameters().get('caseId');//'500Q0000003woSF';
        
   
        
        String queryString = 'select id,name from Case_Product__c where case__c IN (\'' + caseId + '\')';
        tempCaseProd = database.query(queryString);
        system.debug(tempCaseProd);
        for(Case_Product__c cp:tempCaseProd){CaseProdIds.add(cp.id);}
        for(Problem__c p:[select id,name,case_product__c from Problem__c where Case_Product__c=:CaseProdIds]){
            if(CaseProdProbMap.containsKey(p.case_product__c)){
                CaseProdProbMap.get(p.case_product__c).add(p);//adds problems for this case product to the problems list in the map    
            }else{
                CaseProdProbMap.put(p.case_product__c,new List<Problem__C>{p});//adds new problem list for this case product to the map    
            }
        }
        for(Case_Product__c cp2:tempCaseProd){
            wrapper tmpwrapper = new wrapper();
            tmpwrapper.caseProd=cp2;
            List<wrapper2> t2 = new List<wrapper2>();
            for(Problem__c pp:CaseProdProbMap.get(cp2.id)){
                wrapper2 twrap2 = new wrapper2();
                twrap2.Prob=pp;
                t2.add(twrap2);
            }
            tmpwrapper.problems=t2;
            wrapout.add(tmpwrapper);
        }


        return null;
    }

    
}

 

So we've exceeded our storage limits and it appears 75% of our storage is taken up by tasks (~1 million), specifically mass emails logged as an activity.  What would be the best way to go about deleting these emails?  I tested Data Loader in our sandbox previously to query all the mass email tasks, export the Ids, and then delete the associated tasks.  This seemed like it should work, but the quota in the sandbox never updated (2-3 weeks) to refelct the new usage.

 

Any ideas?  Thanks!

I have some apex code that queries the opportunity and opportunitylineitem tables orders by sortorder and then sends an xml off to a back office ERP system to create a sales order.  My users want the order of the lines on the sales order to appear in the same order as the opportunity lines on the opportunity.  Ordering the query results by sortorder works when a user has specified a specific order for the products, otherwise it doesn't work because sortorder is null.  What would the best way to get around this?  Check to see if sortorder is null then us the list.sort function to sort the list by product name?  Any ideas would be appreciated, thanks!

Say I have an Opportunity, how do I return the results for that opportunities OpportunityLineItems in order that they appear in the related list on the opp page?

 

Thanks!

I'm trying to enter a new pricebookentry into the standard price book (which is inactive), but I can't get any results querying for the Standard Price Book (planning on setting inactive to false) through the test class.  Here's the error I get:

 

System.QueryException: List has no rows for assignment to SObject

 

And here is the query:

PriceBook2 pbStd = [SELECT Id, IsActive FROM PriceBook2 WHERE Name = 'Standard Price Book'];

 

When I run the same query in the Force IDE I get the record.

 

Any thoughts?  


I'm not getting any data to display in my email template when passing the caseId to query the Case_Product_Name and Serial_Number__c fields from the "Problem" object.  I do get data when I hard code the caseId in the getSerials setter.  Keep in mind the case_id__c field is a string data type on the problem object" (its a formula field to make this email template easier to create intead of building a wrapper classs to get the data... the relationship between the objects are amaster-detail from Case to Case Product to Problem).

 

Any help would be greatly appreciated!  Thanks!

 

Email Template:

<messaging:emailTemplate subject="test" recipientType="Contact" relatedToType="Case">
    <messaging:htmlEmailBody >

        <c:Case_Product_Serials paramCaseId="{!relatedTo.Id}"/>          
    
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

 

Component:

<apex:component controller="caseProductSerials" access="global">
    <apex:attribute name="paramCaseId" type="Id" description="Case Id parameter" assignTo="{!caseId}"/>
                <apex:repeat value="{!serials}" var="serial">
                   <apex:outputText value="{!serial.case_product_name__c}" />
                </apex:repeat>
 </apex:component>

 Controller:

public class caseProductSerials {
    
    Public Id caseId {get;set;}
    Public List<Problem__c> serials = new List<Problem__c>();
    
    public caseProductSerials() {
    }
    
    public List<Problem__c> getserials(){
        return [SELECT case_product_name__c, serial_number__c FROM problem__c where case_id__c =: caseId]; //'500Q0000003woSF'];
    }
    
}

 

 

I'm not getting any data to display in my email template when passing the caseId to query the Case_Product_Name and Serial_Number__c fields from the "Problem" object.  I do get data when I hard code the caseId in the getSerials setter.  Keep in mind the case_id__c field is a string data type on the problem object" (its a formula field to make this email template easier to create intead of building a wrapper classs to get the data... the relationship between the objects are amaster-detail from Case to Case Product to Problem).

 

Any help would be greatly appreciated!  Thanks!

 

Email Template:

<messaging:emailTemplate subject="test" recipientType="Contact" relatedToType="Case">
    <messaging:htmlEmailBody >

        <c:Case_Product_Serials paramCaseId="{!relatedTo.Id}"/>          
    
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

 

Component:

<apex:component controller="caseProductSerials" access="global">
    <apex:attribute name="paramCaseId" type="Id" description="Case Id parameter" assignTo="{!caseId}"/>
                <apex:repeat value="{!serials}" var="serial">
                   <apex:outputText value="{!serial.case_product_name__c}" />
                </apex:repeat>
 </apex:component>

 Controller:

public class caseProductSerials {
    
    Public Id caseId {get;set;}
    Public List<Problem__c> serials = new List<Problem__c>();
    
    public caseProductSerials() {
    }
    
    public List<Problem__c> getserials(){
        return [SELECT case_product_name__c, serial_number__c FROM problem__c where case_id__c =: caseId]; //'500Q0000003woSF'];
    }
    
}

 

 

Say I have an Opportunity, how do I return the results for that opportunities OpportunityLineItems in order that they appear in the related list on the opp page?

 

Thanks!

I'm trying to enter a new pricebookentry into the standard price book (which is inactive), but I can't get any results querying for the Standard Price Book (planning on setting inactive to false) through the test class.  Here's the error I get:

 

System.QueryException: List has no rows for assignment to SObject

 

And here is the query:

PriceBook2 pbStd = [SELECT Id, IsActive FROM PriceBook2 WHERE Name = 'Standard Price Book'];

 

When I run the same query in the Force IDE I get the record.

 

Any thoughts?  


Hello all,

 

I have a requirement for a visualforce page which would repeat tables of account related information. Now i can do this easily if its just an object with one single related object. However if i have for example an Account, then a related object, then an object related to that related object i find that it becomes a little more challenging because soql can only return 1 inner object. 

 

So, i know a wrapper class is the suggested resolution to this problem. However they are very poorly documented and i cannot 'wrapper' my head around them. lol terrible i know. For instance i don't know how i can build a list with all of these related objects to use in the visual force page.

 

So if someone could please walk me (and i'm sure countless others) through this process that would be greatly greatly appreciated. 

 

Here is what i'm trying to do:

 

Relating multiple=