+ Start a Discussion
Jim MontgomeryJim Montgomery 

failed to trigger a flow

Here is my trigger and test class. I can create an account with the exact same properties as they account in the test class, and it works fine. But thr test class fails with this error.
Error:
System.DmlException: Update failed. First exception on row 0 with id 0010x00000FTfC0AAL; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, RCLeadAutoCreateFromAccount: execution of AfterUpdate

caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3010x0000000W9o. Flow error messages: <b>An unhandled fault has occurred in this flow</b><br>An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.: []

Trigger.RCLeadAutoCreateFromAccount: line 24, column 1: []
Stack TraceClass.TestRCLeadAutoCreate.insertAccount: line 27, column 1


Trigger:
trigger RCLeadAutoCreateFromAccount on Account (after update) {
    for (Account A:Trigger.New){
    String Name = UserInfo.getName();
         Account oldAccount = Trigger.oldMap.get(A.Id);
        if(oldAccount.RC_Lead_TimeStamp__c != A.RC_Lead_TimeStamp__c){
        Campaign C = [select id from campaign where name = '18--support-phone inbound-torrance'];
              Lead L = new Lead(
                company = A.name,
                status = 'Not Started',
                lastname = 'RC Lead',
                rating = 'Hot',
                market_segment__c = A.Market_Segment__c,
                market_sub_segment__c = A.Market_Sub_Segment__c,
                street = a.billingstreet,
                city = a.billingcity,
                state = a.billingstate,
                PostalCode = a.BillingPostalCode,
                named_account_type__c = a.Named_Account_Type__c,
                related_account__c = a.Id,
                description = a.rc_lead_comments__c,
                rc_lead_product_interest__c = a.rc_lead_product_interest_MS__c);
            insert L;
            if(A.Named_Account_Type__c == 'Small Firm Tax Customer'){
                L.small_market_N2E__c = True;
                update L;
            }
            campaignmember CM = new campaignmember(
                campaignID = C.Id, 
                comments__c = a.rc_lead_comments__c,             
                leadID = L.ID
                    );
                insert cm;
                             
        }
        
    
    }
}

Test Class:
@isTest 
private class TestRCLeadAutoCreate {

    static testMethod void insertAccount() {
    string name = 'Jim Montgomery';
   Account A = new Account(
            Name = 'myAcct', 
            BillingStreet='25 Upland Drive',
            BillingPostalCode='94127',
            BillingCountry='United States',
            BillingCity='San Francisco',
            market_segment__c = 'Accounting Firms',
            market_sub_segment__c = 'Sole Proprietor',
            billingstate = 'CA',
            named_account_type__c = 'Strategic',
            rc_lead_comments__c = 'Test',
            rc_lead_product_interest_ms__c = 'Pfx Tax'
            );
        insert A;
        Campaign Cam = new Campaign(
        name = '18--support-phone inbound-torrance',
        type = 'Direct mail',
        isactive = true);
        insert Cam;
        
        a.rc_lead_timestamp__c = system.now();
        update a;
        }
        }
Best Answer chosen by Jim Montgomery
Maharajan CMaharajan C
Hi Jim,

Check did you any Process builder in the ACCOUNT object.

To pass the test class

1. you have to change the test class to don't meet the criteria in Process builder ,

2. or you have to change the process builder properly 

3. Check deactivate the Process builder and run the test Class.

Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!


Thanks,
Raj

All Answers

Maharajan CMaharajan C
Hi Jim,

Check did you any Process builder in the ACCOUNT object.

To pass the test class

1. you have to change the test class to don't meet the criteria in Process builder ,

2. or you have to change the process builder properly 

3. Check deactivate the Process builder and run the test Class.

Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!


Thanks,
Raj
This was selected as the best answer
Jim MontgomeryJim Montgomery
Thanks! Had to deactivate the lead processes one at a time to find the offender.