+ Start a Discussion
Thomas DehliThomas Dehli 


I have some custom Apex classes that are failing to save Opportunitty records when a certain flow is enabled in the process builder. When I disable the process in Process Builder, everything starts working again.

The error I get is:
Update failed. First exception on row 0 with id 0063800000WBq80AAD; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow.

java.lang.IllegalArgumentException: unable to find field dataType for complex reference

Error is in expression '{!saveOpp}' in page editexecutivesummary: Class.OpportunityExecutiveSummaryController.saveOpp: line 128, column 1
I need some help figuring out why my Apex class is failing on all opportunities in any stage, as my process in Process Builder is not even suppose to fire until 'Closed Won' is TRUE.

The methos that is failing:
    public PageReference saveOpp(){
        if(exe_summary != null && exe_summary.trim().length() > 0){
            opp.Executive_Summary_R__c = exe_summary;
            //exe_summary = exe_summary.replace('<p>','').replace('</p>','\n').replace('<br />','\n').replace('<br>','\n').replace('\'','');
            //exe_summary = exe_summary.replace('<[^>]+>',' ').replace('&amp;','&').replace('&lt;','<').replace('&gt;','>').replace('&quot;','"').replace('&#39;','\'').replace('&nbsp;',' ');
            opp.Executive_Summary__c = mergeFieldValues(exe_summary);            
            opp.Estimated_Travel_Costs__c = 0;
        update opp;
        return new PageReference('/apex/EditExecutiveSummary?updated=true&id='+opp_id).setRedirect(true);

Thomas DehliThomas Dehli

If I disable this process, the Apex class and 'update opp;' starts to work again?


User-added image

Thomas DehliThomas Dehli
Perhaps this helps? Is there something wronf with using [Opportunity].StageName ?

User-added image
Ines CortesInes Cortes
Hi Thomas,
were you able to figure this issue out? We are running into the same situation with one of our flows. The update we are doing to the record is not even supposed to trigger the flow because it does not meet its criteria, but yet the error gets thrown and update fails. Just wondering if you figured out the solution to this or if you found a workaround.

Thank you,
Rich FiekowskyRich Fiekowsky
For me this happened, and went away, when I was doing the challenge of the Trailhead module about Process Builder (copying the Account address to all its Contact children).  
It happened when I mistakenly used "String" in the type-of-value column in the Action rows that replace the fields of the address; so I was setting the Opportunity->Mailing Postal Zip Code field to "Shipping Postal Zip Code", so, it did not fit, so, RT error.
Instead, the type of value should be "Reference", and in the final column, the field Opportunity->Account->Shipping Postal Zip Code  should be chosen. After I fixed all five fields this way, it works.