I have a trigger that is triggered before update or before insert
for(CustomerProfile__c cp : listCustomerProfiles){
if(...){
cp.addError('A Customer Profile record has
already been created for this brand.');
}
And in the test class i am using only insert listOfRecord
and not Database.insert(listOfRecords,false)
Data is imported using the dataloader or api so i cannot use Database.insert(listOfRecords,false)
in order to bypass the records on which the addError()
method is invoked. I know that by using addError()
on 1 record will neglect the DML and do a roll back.
Is there anyway to only insert/update the records that don't meet the condition and for the records who meet the condition to NOT include them in the DML operation and also sending an error or message for each one?