• Tommy C
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Hi all,

I have some code that I would like to ensure updates from the child Opportunities to the parent Opportunity, which is a renewal. Right now, I have a beforeUpdate trigger that looks to see if the Opportunity has any children opportunities. If it does, then it will sum up the values of Currency1__c, Currency2__c, and Currencye3__c from the child opportunities into the parent's Opp fields rollupCurrency1,rollupCurrency2 , and rollupCurrency3. I have this part written out.

The second part is a little difficult for me to figure out. Essentially, I want it so that if any of three specific Currency fields are changed on the child opportunity, it should trigger an update in the parent Opportunity. They are associated via a lookup field. Since it's the same object, I'm not sure what the best practice would be to update the parent Opportunity when the Opp Trigger is triggered from the child Opportunity since it's not passed in Trigger.New, and DML operations don't work on the same object if I recall correctly. Any help is appreciated! 

 
Hi, I'm having some issues with getting the Contact IDs from their emails. I have a list of emails (around 1000 users) that I want to get their Contact IDs for. Using a VLookup table isn't the most efficient because there are over 3 million Contact records to sort through. If there's an easier way, let me know! 

I tested the code below and it returns only the first value of the list of emails. When I do the query for [SELECT id, name, email FROM Contact WHERE email IN :emails], it only returns one object. What am I doing wrong? 

String users = 'johnny@abc.com, jimmy@abc.com, jonas@abc.com'
List<String> emails = users.split(',');

public static Map<String, id> contactIDFromEmail(List<String> emails){
        Map<String, id> cm = new Map<String, id>();
        Contact[] c = [SELECT id, name, email FROM Contact WHERE email IN :emails];
        for(Contact cont : c){
            cm.put(cont.email, cont.id);
        }
        return cm;
    }
  • September 28, 2018
  • Like
  • 0
I have an object called Past Products that is normally created when a new child Opportunity is created. These Past Products objects are associated with the child Opp and are created from the parent Opportunity's Products. Currently, there is a code that creates these Past Products when a new child Opportunity is created from its parent. However, if the child Opportunity is created separately and is assigned a parent afterwards, these Renewals are not created. These Past Products show up in a Related Record List for the child Opportunity.   

Essentially, given the child Opportunity, I want to pull all the Products from the parent Opportunity and create Past Products objects for each of those products and associate these Past Product objects with the child Opportunity.  I want to be able to add a button or some trigger to manually call this method. The code already exists to create these Past Product objects so it's either a matter of calling this method or replicating its function.  

Would it be possible to call this Apex method from the Process Builder or a Button? Could it be done through a workflow? If I can also replicate what the code does (creating the Past Product objects) in Process Builder or a Workflow without needing to call the method, that also works. I'm new to the platform so I will appreciate any help! 
Hi, I'm having some issues with getting the Contact IDs from their emails. I have a list of emails (around 1000 users) that I want to get their Contact IDs for. Using a VLookup table isn't the most efficient because there are over 3 million Contact records to sort through. If there's an easier way, let me know! 

I tested the code below and it returns only the first value of the list of emails. When I do the query for [SELECT id, name, email FROM Contact WHERE email IN :emails], it only returns one object. What am I doing wrong? 

String users = 'johnny@abc.com, jimmy@abc.com, jonas@abc.com'
List<String> emails = users.split(',');

public static Map<String, id> contactIDFromEmail(List<String> emails){
        Map<String, id> cm = new Map<String, id>();
        Contact[] c = [SELECT id, name, email FROM Contact WHERE email IN :emails];
        for(Contact cont : c){
            cm.put(cont.email, cont.id);
        }
        return cm;
    }
  • September 28, 2018
  • Like
  • 0