You need to sign in to do that
Don't have an account?
ram sb
Apex Trigger Before Update Issue
Trigger not updating the records.When I Debug the Trigger.I am getting the following error like: Update failed. First exception on row 0 with id XXX; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Case_Staging: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 1 with id XXX.
Could any one please help to resolve the error? Thank you very much!
Apex Trigger
Could any one please help to resolve the error? Thank you very much!
Apex Trigger
trigger Case_Staging on Case_Staging__c (before insert, before update) { if(Trigger.isBefore && Trigger.isUpdate) Case_Staging_TriggerHandler.beforeUpdate(Trigger.new, Trigger.oldMap); }Trigger Handler
public class Case_Staging_Utility { // Case Staging Statuses public static String CASEBUILD_STATUS() {return 'Case Build';} public static String APPROVED_STATUS() {return 'Approved';} public static String REJECTED_STATUS() {return 'Rejected';} // returns map w key of Case_Staging__c and a list of related parties public static Map<Id, List<Party__c>> getRelatedParties(List<Case_Staging__c> cs) { Map<Id, List<Party__c>> relatedPartiesByCaseStagingIdMap = new Map<Id, List<Party__c>>(); for(Party__c p : [SELECT Id, Case__c, Case_Staging__c FROM Party__c WHERE Case_Staging__c IN :cs]) { if(relatedPartiesByCaseStagingIdMap.get(p.Case_Staging__c) == null) relatedPartiesByCaseStagingIdMap.put(p.Case_Staging__c, new List<Party__c>()); // sort by case_staging__c List<Party__c> relatedParties = relatedPartiesByCaseStagingIdMap.get(p.Case_Staging__c); relatedParties.add(p); relatedPartiesByCaseStagingIdMap.put(p.Case_Staging__c, relatedParties); } return relatedPartiesByCaseStagingIdMap; } // returns map w key of Case_Staging__c and a list of related representative__c public static Map<Id, List<Representative__c>> getRelatedRepresentatives(List<Case_Staging__c> cs) { Map<Id, List<Representative__c>> relatedRepsByCaseStagingIdMap = new Map<Id, List<Representative__c>>(); for(Representative__c r : [SELECT Id, Case__c, Case_Staging__c FROM Representative__c WHERE Case_Staging__c IN :cs]) { if(relatedRepsByCaseStagingIdMap.get(r.Case_Staging__c) == null) relatedRepsByCaseStagingIdMap.put(r.Case_Staging__c, new List<Representative__c>()); // sort by case_staging__c List<Representative__c> relatedReps = relatedRepsByCaseStagingIdMap.get(r.Case_Staging__c); relatedReps.add(r); relatedRepsByCaseStagingIdMap.put(r.Case_Staging__c, relatedReps); } return relatedRepsByCaseStagingIdMap; } // returns map w key of Case_Staging__c and a list of related event_filing__c public static Map<Id, List<Event_Filing__c>> getRelatedEventFilings(List<Case_Staging__c> cs) { Map<Id, List<Event_Filing__c>> relatedEventFilingsByCaseStagingIdMap = new Map<Id, List<Event_Filing__c>>(); for(Event_Filing__c ev : [SELECT Id, Case__c, Case_Staging__c FROM Event_Filing__c WHERE Case_Staging__c IN :cs]) { if(relatedEventFilingsByCaseStagingIdMap.get(ev.Case_Staging__c) == null) relatedEventFilingsByCaseStagingIdMap.put(ev.Case_Staging__c, new List<Event_Filing__c>()); // sort by case_staging__c List<Event_Filing__c> relatedEventFilings = relatedEventFilingsByCaseStagingIdMap.get(ev.Case_Staging__c); relatedEventFilings.add(ev); relatedEventFilingsByCaseStagingIdMap.put(ev.Case_Staging__c, relatedEventFilings); } return relatedEventFilingsByCaseStagingIdMap; } }
The provided error message is not clear.So,can you please share the complete error message.Also,please capture the debug logs to see,whichis causing the issue.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
Debug log:
The above post I have posted Trigger and Trigger Utility
Trigger Handler
Can you please create the case with the salesforce.com support since you are getting the Gack error.We can take a look and will provide you more details.
Thank you!
Regards,
Shirisha Pathuri
To help your troubleshooting, questions:
Is this code already in Production? or Sandbox?
If it's Production, what changed in Production since it can't be code as it gets deployed? Is there a new Process Builder? Change in FLS?
If testing in sandbox,
Is there a Process Builder called “Union and Employer Info Copied to Case”? If so, what happens if we deactivate the Flow and run the Trigger?
The code errors seem to point to the Event_Filings records being updated. (noting a small descrepancy between code line numbering and the line numbers in the log). Do these (Event_Filings) do some update which fires the Process Builder noted above?
I would also check the security model as well (both object and field) of all the objects involved in the code process. Particularly that Event Filing object and anything affected by the process “Union and Employer Info Copied to Case”
happy hunting
Andrew
This functionality was working in the production before Spring'20 platform realse. "Union and Employer Info Copied to Case" in flows. Do we have any latest updates in flows?
I can create a case to salesforce to understand latest flow updates.