Skip to main content
pooja biswas 님이 #Apex에 질문했습니다
Hi

I have a class which will update account field and contact field if some change occurs in opportunity.

I am calling instance of this class inside trigger written on opportunity object.

I am using Database.Update statement to perform DML .

Now if an error occurs while updating the contact field, then I should roll back the entire transaction including account.

Please let me know how to achieve this.

Thanks

Pooja
답변 1개
  1. 2017년 1월 27일 오전 5:33
    Hello pooja,

    Try specifying a boolean parameter allorNone along the with list of sobject to update .

    For Eg:

    Database.update(ListofAccounts,true);

    This will rollback all the transaction in the context .

    check for the following method in Database class.

    update(recordToUpdate, allOrNone)

    https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_database.htm

    Please let us know, if this solves your problem.

    Thanks
0/9000