You need to sign in to do that
Don't have an account?
Tyler Schryver
Error Occurred During Flow "Activity_Update_for_Visual_Workflow":UPDATE --- UPDATE FAILED ---- ERRORS: ...
I have this Trigger:
With this Test Class:
When I run the Test Class I get the following email from a Process Flow that is being executed:
Can someone point out the error of my ways?
trigger OnBoardingUpdateFromTask on Task (after update) { List<Customer_OnBoard__c> OnBoardingsToUpdate = new List<Customer_OnBoard__c>(); Map<Id, Customer_OnBoard__c> OnBoardingIDToOnBoardingObjMap = new Map<Id, Customer_OnBoard__c>(); for (Task t: Trigger.new) { if (t.subject=='AWF: RealTime Project Kick Off' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Project_Kick_Off_rt__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Traveler Project Kick-Off' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Project_Kick_Off_TR__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Update Monthly Billing for Customer' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Monthly_Billing_Update__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Renewal Monthly Billing Update' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Renewal_Monthly_Billing__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Decommission Monthly Billing Update' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Decommission_Monthly_Billing_Update__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Decommission Hardware' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Decommission_Hardware__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Decommission OnDemand Vehicles' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Decommission_Vehicles__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Enable Additional Vehicles' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Enable_Additional_Vehicles__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: OnDemand Project Kick-Off' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Project_Kick_Off_OD__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Order Inventory' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Order_Inventory__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Confirm OSM Region Added' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Confirm_OSM_Added__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Finance Confirm Payment Received' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Finance_Confirm_Payment__c = TRUE; o.Confirm_Payment__c = TRUE; o.Confirm_Payment_Count__c = 1; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Confirm Receipt of SIS' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Confirm_SIS_Received__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: GTFS and Backend Setup' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Create_GTFS_Feed_and_Backend_Setup__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Enable Survey' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Enable_Survey__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Send the SIS to Customer' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Send_the_SIS_to_the_Customer__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: RealTime New Product Training' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.New_Product_Training_rt__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Traveler New Product Training' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.New_Product_Training_TR__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: OnDemand New Product Training' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.New_Product_Training_od__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Preview Period' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Preview_Period__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: RealTime Product Go Live' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Product_Go_Live_RT__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Traveler Product Go Live' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Product_Go_Live_TR__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: OnDemand Product Go-Live' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Product_Go_Live_OD__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Provide Credentials to Agency' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Provide_Credentials_to_Agency__c = TRUE; o.Date_OnDemand_Ready__c = Date.today(); OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Request Logo' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Request_Logo__c = TRUE; o.Date_Traveler_Ready__c = Date.TODAY(); OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Ship Units To Customer' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Ship_Units_To_Customer__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Enable Go-Live' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Weekly_Tasks__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Schedule Travel' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Schedule_Travel__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Check Inventory' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Check_Inventory__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Order Inventory' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Order_Inventory__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Update Inventory' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Update_Inventory__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Submit Expense Form' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Expense_Form__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Decommission Hardware' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.Hardware_Decommissioned__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } if (t.subject=='AWF: Decommission OnDemand Vehicles' && t.Status =='Completed') { if(OnBoardingIDToOnBoardingObjMap.get(t.WhatId) == null){ Customer_OnBoard__c o = new Customer_OnBoard__c(Id=t.WhatId); o.OnDemand_Decommission_Product__c = TRUE; OnBoardingIDToOnBoardingObjMap.put(t.WhatId, o); } } for(Id id : OnBoardingIDToOnBoardingObjMap.keyset()){ Customer_OnBoard__c thisOnb = new Customer_OnBoard__c(); thisOnb = OnBoardingIDToOnBoardingObjMap.get(id); OnBoardingsToUpdate.Add(thisOnb); } try { update OnBoardingsToUpdate; } catch (system.Dmlexception e) { system.debug (e); } } }
With this Test Class:
@isTest (seeAllData=false) private class TestOnBoardingUpdateFromTask { public static List<Task> tasksList; public static List<Opportunity> opportunitiesList; public static List<Account> accountsList; public static String subject; static void init(){ tasksList = new List<Task>(); opportunitiesList = new List<Opportunity>(); accountsList = new List<Account>(); accountsList.add(new Account(Name = 'Test', Sales_Region__c = '1 - Southeast', Type = 'Prospect' )); opportunitiesList = new List<Opportunity>{ new Opportunity( Name = 'Test1', CloseDate = date.today().addDays(5), AccountId = accountsList[0].Id, Type = 'New Business', TransLoc_Hardware__c = 'Yes', Integration__c = 'NO', StageName = 'Proposal'), new Opportunity( Name = 'Test2', CloseDate = date.today().addDays(5), AccountId = accountsList[0].Id, Type = 'New Business', TransLoc_Hardware__c = 'Yes', Integration__c = 'NO', StageName = 'Proposal'), new Opportunity( Name = 'Test3', CloseDate = date.today().addDays(5), AccountId = accountsList[0].Id, Type = 'New Business', TransLoc_Hardware__c = 'Yes', Integration__c = 'NO', StageName = 'Proposal'), new Opportunity( Name = 'Test4', CloseDate = date.today().addDays(5), AccountId = accountsList[0].Id, Type = 'New Business', TransLoc_Hardware__c = 'Yes', Integration__c = 'NO', StageName = 'Proposal'), new Opportunity( Name = 'Test5', CloseDate = date.today().addDays(5), AccountId = accountsList[0].Id, StageName = 'Proposal') }; } static testMethod void testWithExistingTask() { init(); Test.startTest(); tasksList = new List<Task>{new Task( Subject = subject, Status='Completed', Priority = 'Normal' ), new Task(Subject='AWF: RealTime Project Kick Off', Status ='Completed'), new Task(Subject='AWF: RealTime New Product Training' , Status='Completed'), new Task(Subject='AWF: RealTime Product Go Live' , Status='Completed'), new Task(Subject='AWF: Check Inventory', Status='Completed'), new Task(Subject='AWF: Order Inventory' , Status='Completed'), new Task(Subject='AWF: Start Installation Checklist' , Status='Completed'), new Task(Subject='AWF: Ship Units To Customer' , Status='Completed'), new Task(Subject='AWF: Submit Expense Form' , Status='Completed'), new Task(Subject='AWF: Update Inventory' , Status='Completed'), new Task(Subject='AWFl Schedule Travel', Status = 'Completed'), new Task(Subject='AWF: OnDemand Product Go-Live' , Status='Completed'), new Task(Subject='AWF: OnDemand Project Go Live' , Status='Completed'), new Task(Subject='AWF: OnDemand Project Kick-Off' , Status='Completed'), new Task(Subject='AWF: OnDemand New Product Training' , Status = 'Completed'), new Task(Subject='AWF: Traveler New Product Training' , Status='Completed'), new Task(Subject='AWF: Traveler Product Go Live' , Status='Completed'), new Task(Subject='AWF: Traveler Project Kick-Off' , Status='Completed'), new Task(Subject='AWF: Preview Period' , Status='Completed'), new Task(Subject='AWF: Request Logo' , Status='Completed'), new Task(Subject='AWF: Confirm Receipt of SIS' , Status='Completed'), new Task(subject='AWF: Provide Credentials To Agency' , Status='Completed'), new Task(Subject='AWF: Enable Survey' , Status='Completed'), new Task(Subject='AWF: GTFS and Backend Setup' , Status = 'Completed'), new Task(Subject='AWF: Enable Go-Live', Status='Completed') , new Task(Subject='AWF: Confirm OSM Region Added', Status ='Completed'), new Task(Subject='AWF: Enable Additional Vehicles' , Status = 'Completed'), new Task(Subject='AWF: Decommission OnDemand Vehicles', Status = 'Completed'), new Task(Subject='AWF: Decommission Hardware' , Status = 'Completed'), new Task(Subject='AWF: Finance Confirm Payment Received' , Status = 'Completed'), new Task(Subject='AWF: Decommission Monthly Billing Update' , Status = 'Completed'), new Task(Subject='AWF: Renewal Monthly Billing Update' , Status = 'Completed'), new Task(Subject='AWF: Update Monthly Billing for Customer' , Status = 'Completed') }; insert accountsList; insert opportunitiesList; insert tasksList; tasksList = [ SELECT Id, WhatId FROM Task ]; //if (!tasksList.isEmpty()){ Integer i = 0; for(Task t : tasksList){ t.WhatId = opportunitiesList[i].Id; //i++; } update tasksList; //System.assertEqual(tasksList[0].WhatId, opportunitiesList[0].Id); //Test.stopTest(); } }
When I run the Test Class I get the following email from a Process Flow that is being executed:
An error occurred at element myRule_5_A1 (FlowRecordUpdate). UPDATE --- UPDATE FAILED --- ERRORS : (LIMIT_EXCEEDED) System.LimitException: Too many DML statements: 151 ________________________________________ This report lists the elements that the flow interview executed. The report is a beta feature. We welcome your feedback on IdeaExchange. Flow Details Flow Name: Activity_Updates_for_Visual_Workflow Type: Workflow Version: 14 Status: Active Flow Interview Details Interview Label: Activity_Updates_for_Visual_Workflow-14_Task Current User: Chris Fraser (005d00000066RvV) Start time: 11/3/2016 3:12 PM Duration: 0 seconds How the Interview Started Chris Fraser (005d00000066RvV) started the flow interview. Some of this flow's variables were set when the interview started. myVariable_old = null myVariable_current = 00TP000000FJyvpMAD RecursiveCountVariable = 2.00 ASSIGNMENT: myVariable_waitStartTimeAssignment {!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime} Result {!myVariable_waitStartTimeVariable} = "11/3/2016 3:12 PM" DECISION: myDecision DECISION: myDecision2 DECISION: myDecision4 Executed this outcome: myRule_5 Outcome conditions: and 1. {!myVariable_current.Subject} (AWF: OnDemand New Product Training) Contains OnDemand New Product Training 2. {!myVariable_current.IsClosed} (true) Equals true Logic: All conditions must be true (AND) RECORD UPDATE: myRule_5_A1 Find all Task records where: Id Equals {!myVariable_current.Id} (00TP000000FJyvpMAD) Update the records’ field values. New_Product_Training_od__c = true Result Failed to update records that meet the filter criteria. ________________________________________ Error Occurred: UPDATE --- UPDATE FAILED --- ERRORS : (LIMIT_EXCEEDED) System.LimitException: Too many DML statements: 151 ________________________________________ ________________________________________
Can someone point out the error of my ways?
You are creating around 40 TASKS using the Test class and seems like the Visual flow is getting fired based on newly created TASKS and inturn invokes the TASK Trigger and fires visual flow again (may be recursive).
Please enable debug logs and see what exactly happening in the background.
You need to include additional conditions to restrict Visual flow to fire and update TASK records all the times if possible.
All Answers
You are creating around 40 TASKS using the Test class and seems like the Visual flow is getting fired based on newly created TASKS and inturn invokes the TASK Trigger and fires visual flow again (may be recursive).
Please enable debug logs and see what exactly happening in the background.
You need to include additional conditions to restrict Visual flow to fire and update TASK records all the times if possible.