3 respostas

Hi Sandeep, You can use the below method to get the reason for failure of records.insert(recordToInsert, allOrNone)Adds an sObject, such as an individual account or contact, to your organization's data.Signaturepublic static Database.SaveResult insert(sObject recordToInsert, Boolean allOrNone)ParametersrecordToInsertType: sObjectallOrNoneType: BooleanThe optional allOrNone parameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.Return ValueType: Database.SaveResultUsageinsert is analogous to the INSERT statement in SQL.Apex classes and triggers saved (compiled) using API version 15.0 and higher produce a runtime error if you assign a String value that is too long for the field.Each executed insert method counts against the governor limit for DML statementsLink:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_database.htm⌗apex_System_Database_insert