I have an apex class that was written by a previous SF Admin and I'm trying to understand why it isn't working. From what I can tell, it is supposed to auto-populate the Account Name that is associated the Opportunity that this custom object (Campaign Design Profile) record is being created on. When select the New button to create the custom record on the Opportunity, the Account Name field is not pre-populated when creating the record. I also tried just populating in process builder via a field reference immediate action and that doesn't pre-populate either. This class passes the test in the sandbox, but fails in production:
Error Message System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, We can't save this record because the “Update Opp with Master CDP & Campaign Type” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to update records: CANNOT_EXECUTE_FLOW_TRIGGER: We can't save this record because the “Requested Dates” process failed.
Give your Salesforce admin these details. This error occurred when the flow tried to update records: LIMIT_EXCEEDED: System.LimitException: Too many query rows: 50001. You can look up ExceptionCode values in the SOAP API Developer Guide.. You can look up ExceptionCode values in the SOAP API Developer Guide.: []
Stack Trace
Class.CampaignDesignProfileTrigger.testCampaignDesignProfileTrigger: line 53, column 1
public with sharing class CampaignDesignProfileTrigger {
public void updateAccount(List<Campaign_Design_Profile__c> newProfiles){
//This procedure will update the Account_Name_Ref__c with the
//Account Id on the related Opportunity.
Map<Id, Id> oppAccountIds = new Map<Id, Id>();
List<Id> oppIds = new List<Id>();
//Retrieving the Opportunity Ids for the new records
for(Campaign_Design_Profile__c p : newProfiles){
oppIds.add(p.Related_Opportunity__c);
}
//Populating the oppAccountIds map with the Opp Id/Acct Id for lookup later
for(Opportunity o : [Select Id, AccountId From Opportunity Where Id in:oppIds]){
oppAccountIds.put(o.Id, o.AccountId);
}
for(Campaign_Design_Profile__c p : newProfiles){
p.Account_Name_Ref__c = oppAccountIds.get(p.Related_Opportunity__c);
}
}
static testMethod void testCampaignDesignProfileTrigger(){
test.startTest();
//Retrieving Record Types
List<RecordType> rec_type = [Select Id From RecordType
Where IsActive=true And SobjectType = 'Campaign_Design_Profile__c' Limit 1];
//Creating a test Account
Account acct = new Account(Name='CampaignDesignProfileTest Account');
insert acct;
//Creating a test Opportunity
Opportunity opp = new Opportunity(Name='CampaignDesignProfileTest Opportunity', AccountId=acct.Id,
StageName='Needs Analysis', CloseDate=system.today());
insert opp;
//Creating a test Campaign Design Profile
Campaign_Design_Profile__c cdp = new Campaign_Design_Profile__c(Name='CampaignDesignProfileTest cdp',
Campaign_Type__c='Account Profiling', Related_Opportunity__c=opp.Id);
cdp.Estimate_Type__c = 'N/A';
cdp.Volume__c =14.00;
cdp.of_Hours__c =15.00;
insert cdp;
test.stopTest();
}
}
CampaignDesignProfileTrigger
class calling? andRelated_Opportunity__c
field is mandatory onCampaign_Design_Profile__c
? more info needed