• Ángel HF
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi,

I need help i am stuck and I am not able to continue. I am facing the below issue:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger lastPrimaryQuote caused an unexpected exception, contact your administrator: lastPrimaryQuote: execution of BeforeInsert caused by: System.DmlException: Update failed. First exception on row 0 with id a1O6E000000Cr7ZUAS; 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 3016E000000Cqdx. Flow error messages: An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.: []: Trigger.lastPrimaryQuote: line 14, column 1



My code seems to be fine but I am wondering if i am doing the proper DML call.

Here you are my code.
trigger lastPrimaryQuote on SBQQ__Quote__c (before insert) {

    List<SBQQ__Quote__c> quotes = new List<SBQQ__Quote__c>();
    List<SBQQ__Quote__c> quotesToUpdate = new List<SBQQ__Quote__c>();

    quotes =[select Id, SBQQ__Primary__c,  CreatedDate from SBQQ__Quote__c  where SBQQ__Opportunity2__c =:'0066E000002L4T5'];
    
    for(SBQQ__Quote__c qu : quotes){
        if(qu.SBQQ__Primary__c==true){
            qu.SBQQ__Primary__c=false;
            quotesToUpdate.add(qu);
        }
    }
    update quotesToUpdate;
}




thanks in advance