• Jon Jax
  • NEWBIE
  • 5 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
I'm running into a tough issue where the business case involves parent and children opportunities. There are a few summary fields on the parent that need to be updated based on the sum values of the children. However, if the parent is updated on any of the summary fields, the summary function is disabled (via boolean field) and will not summarize again unless the checkbox is marked false by a system admin. Just as well, upon deletion of a child, the parent will re-summarize. 

I realize process builder is a viable option for some of these functions, but I'd like to write it completely in apex. Also, roll-up summary fields are not an option, as it is not a master-detail relationship. 

I'm currently attempting to use an aggregate soql function to calculate, which works very well, but bulk updating the parent records does not take and I am not sure which trigger context I can even call this from. Any help would be appreciated, attached is the summing method I am currently working with: 
 
//passes in list of parent opportunity Ids to process

public static void sumParentOpp(List<Id> p) {
        System.debug('In sumParentOpp method: ' + p);
        List<Opportunity> oppsToUpdate = new List<Opportunity>();
        
        if(p.size() > 0) {
            List<Opportunity> parentSumOpps = [SELECT Id,
                                               Disable_Summarizing_From_Child__c
                                               FROM Opportunity
                                               WHERE Id IN : p
                                               AND Disable_Summarizing_From_Child__c = FALSE];
            System.debug('Parent Opps that allow summary: ' + parentSumOpps);
            
            if(parentSumOpps.size() > 0){
                List<AggregateResult> childOppSummary = [SELECT
                                                         Parent_Opportunity__c pId,
                                                         SUM(SumField1__c) sF1,
                                                         SUM(SumField2__c) sF2,
                                                         SUM(SumField3__c) sF3
                                                         FROM Opportunity
                                                         WHERE Parent_Opportunity__c IN : parentSumOpps
                                                         GROUP BY Parent_Opportunity__c];
                
                System.debug('Child Opp Summarys: ' + childOppSummary); 
                
                Map<Id,Opportunity> summedParent = new Map<Id,Opportunity>();
                
                for(AggregateResult ar : childOppSummary){
                    Opportunity pOpp    = new Opportunity();
                    pOpp.Id 			= (Id)ar.get('pId');
                    pOpp.Pipeline_kW__c = (Decimal)ar.get('sF1');
                    pOpp.Pipeline_System_Size_kWh__c = (Decimal)ar.get('sF2');
                    pOpp.New_Solar_Pipeline_Size_kW__c = (Decimal)ar.get('sF3');
                    summedParent.put(pOpp.Id, pOpp);
                    System.debug('Summed Parent Opp Created with Sum Values: ' + pOpp);
                }
                for(Opportunity parentOpp : parentSumOpps){
                    Opportunity sParent = summedParent.get(parentOpp.Id);
                    parentOpp.Pipeline_kW__c = sParent.Pipeline_kW__c;
                    parentOpp.Pipeline_System_Size_kWh__c = sParent.Pipeline_System_Size_kWh__c;
                    parentOpp.New_Solar_Pipeline_Size_kW__c = sParent.New_Solar_Pipeline_Size_kW__c;
                    System.debug('Parent Opp Values Updated: ' + parentOpp);
                }
            }       
        
        if(oppsToUpdate.size() > 0){
            update oppsToUpdate;
            System.debug('Updated Opps: ' + oppsToUpdate.size());
        }
        }
    }

 
Hello,
   I am trying to send an email via apex using an html email template (with merge fields) that fires once a certain checkbox is checked on a record and saved. The recipient will be an email address that is another input field on the same record/object, but I would like for it to work like a merge field. I am very new to apex and not exactly sure where to begin with the function and logic combined. Any help would be greatly appreciated! /Jon
Hello,
   I am relatively new to SF and would like to hear some opinions from senior developers/administrators. I am trying to find the best and most strategic way to handle this logistical issue, I will try to explain it very clearly:

I have the following Objects:
  • Jobs
  • Technicians
1. On each Job record detail, several Technicians can be assigned and I want to be able to send each Technician a confirmation email outlining details (merge fields) about the Job. Each Technician will need a different email template that would contain information specific to that Technician.
2. Ideally, I'd like to press one button ("Send Email" )and send those different emails out to those different recipients.
3. I would also like functionality that automatically marks checkbox fields (as True) on the Job layout that shows that those Technicians had been sent the confirmation email. 
4. Sometimes Technicians are changed. So for the final kicker and much more advanced functionality, when a Technician is changed, the associated checkbox field would be unchecked and one could reclick the "Send Email" button and it would only send to the new Technician with an open checkbox next to their name, but not to all of the techs who had already recieved an email. 

I hope this is easy to understand what I am trying to get at. With all that said, what do you think the best approach to this is? Custom Buttons? Flows? Visualforce pages? Apex Implementation? All of the above? Something I haven't considered? I don't neccessarily need specifics, rather a nudge in the right direction. Thanks for your time, your help is greatly appreciated! 
Hello,
    I am stumped! I have dug through the forums as well and nothing that I have found pertains to this specific issue, perhaps it is something really simple that I am missing. Any help would be great, here is my explanation: 

    I have built an email template with merge fields that loads perfectly on its own and linked it to a Custom Button via url link.  This does pull up the email template when the Custom Button is pressed but doesn't show any of the merge fields UNTIL I press the Select Template button and reselect the template that was specified in the url. I would like the merge fields to populate automatically and skip that extra step of having to reselect the email template. Any ideas?  Here is my url:

/_ui/core/email/author/EmailAuthor?&rtype=003&p3_mlktp=a13&p3={!Sales_Order__c.Name}&retURL=%2Fa13/o&p4=test@test.com&p5=test2@test2.com&p24={!Sales_Order__c.Tech_1_Email__c}&p6=Confirmation for {!Sales_Order__c.Job_Code__c}&template_id=00X17000000Qcqq



Thanks! 

 
Hello,
    I am stumped! I have dug through the forums as well and nothing that I have found pertains to this specific issue, perhaps it is something really simple that I am missing. Any help would be great, here is my explanation: 

    I have built an email template with merge fields that loads perfectly on its own and linked it to a Custom Button via url link.  This does pull up the email template when the Custom Button is pressed but doesn't show any of the merge fields UNTIL I press the Select Template button and reselect the template that was specified in the url. I would like the merge fields to populate automatically and skip that extra step of having to reselect the email template. Any ideas?  Here is my url:

/_ui/core/email/author/EmailAuthor?&rtype=003&p3_mlktp=a13&p3={!Sales_Order__c.Name}&retURL=%2Fa13/o&p4=test@test.com&p5=test2@test2.com&p24={!Sales_Order__c.Tech_1_Email__c}&p6=Confirmation for {!Sales_Order__c.Job_Code__c}&template_id=00X17000000Qcqq



Thanks! 

 
Hello,
   I am relatively new to SF and would like to hear some opinions from senior developers/administrators. I am trying to find the best and most strategic way to handle this logistical issue, I will try to explain it very clearly:

I have the following Objects:
  • Jobs
  • Technicians
1. On each Job record detail, several Technicians can be assigned and I want to be able to send each Technician a confirmation email outlining details (merge fields) about the Job. Each Technician will need a different email template that would contain information specific to that Technician.
2. Ideally, I'd like to press one button ("Send Email" )and send those different emails out to those different recipients.
3. I would also like functionality that automatically marks checkbox fields (as True) on the Job layout that shows that those Technicians had been sent the confirmation email. 
4. Sometimes Technicians are changed. So for the final kicker and much more advanced functionality, when a Technician is changed, the associated checkbox field would be unchecked and one could reclick the "Send Email" button and it would only send to the new Technician with an open checkbox next to their name, but not to all of the techs who had already recieved an email. 

I hope this is easy to understand what I am trying to get at. With all that said, what do you think the best approach to this is? Custom Buttons? Flows? Visualforce pages? Apex Implementation? All of the above? Something I haven't considered? I don't neccessarily need specifics, rather a nudge in the right direction. Thanks for your time, your help is greatly appreciated! 
Hi Everyone,

We are using Force.com - App Subscription User License of Salesforce. Everything is working but somehow I can't see Case Tab. In the document nothing is mentioned related to Case Tab.
http://www2.sfdcstatic.com/assets/pdf/misc/DS_Force_Pricing_Comparison.pdf?d=70130000000lzSrAAI
The strange thing is when I logged in as Force.com - App Subscription user case object is visible but tab is not. Any idea why this is happening?Infact I can see email to case too. If case object is not allowed in this license then email to case feature should not be there. Any help will be really appreciated. 

Regards,
Rajiv
 
  • April 27, 2016
  • Like
  • 0
Hello,
    I am stumped! I have dug through the forums as well and nothing that I have found pertains to this specific issue, perhaps it is something really simple that I am missing. Any help would be great, here is my explanation: 

    I have built an email template with merge fields that loads perfectly on its own and linked it to a Custom Button via url link.  This does pull up the email template when the Custom Button is pressed but doesn't show any of the merge fields UNTIL I press the Select Template button and reselect the template that was specified in the url. I would like the merge fields to populate automatically and skip that extra step of having to reselect the email template. Any ideas?  Here is my url:

/_ui/core/email/author/EmailAuthor?&rtype=003&p3_mlktp=a13&p3={!Sales_Order__c.Name}&retURL=%2Fa13/o&p4=test@test.com&p5=test2@test2.com&p24={!Sales_Order__c.Tech_1_Email__c}&p6=Confirmation for {!Sales_Order__c.Job_Code__c}&template_id=00X17000000Qcqq



Thanks!