function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andrew KingAndrew King 

Trigger Error on Custom Object

Hello, and thanks in advance for any suggestions, greatly appreciated!

we created a trigger that queries the accounts and creates custom invoice records for each stop on our service trucks.  each route is designated with a color and a service week per month (week 1, week2, etc) so that when you pick a color and a week, any account that meets that criteria will have an invoice record created.  we created workflows to push fields from the related account to each invidivual invoice record, but these workflows are causing trigger errors on our invoice creation trigger. any idea what to do, based on this error message?

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Logistic_trigger_run caused an unexpected exception, contact your administrator: Logistic_trigger_run: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, A workflow or approval field update caused an error when saving this record. Contact your administrator to resolve it. Division undefined: []: Trigger.Logistic_trigger_run: line 177, column 1
Vinit_KumarVinit_Kumar
Andrew,

As per order of execution in salesforce :-

Workflow runs after Triggers.So,based on the error it seems that the Workflow field update is not getting executed properly and hence the exception which rolls back the Transaction.

the way I would approach is to narrow down which Workflow update is failing by checking the debug logs and then fixing the field update based on the Trigger criteria.

Hope this helps !!
claperclaper
can you post your trigger code?