Can Anyone please help me the code of this
@Divaker Singh @Usman Ali @Sal Caruso
This is a little bit of a weird exercise as they have you looping through a saveresult where you're only creating one record. Plus they don't specify the API names of the fields on Billing__c so I just used what they would be if they're true to the labels. But here you go anyway
Account a = new Account(Name = 'Wipro', Type='Premium');
insert a;
List<Billing__c> billingList = new List<Billing__c>();
Billing__c b = new Billing__c(Billing_Status__c = 'Paid',
Amount_Paid__c = 5000000, b.Account__c = a.Id);
billingList.add(b);
Database.SaveResult[] srList = Database.insert(billingList, false);
for (Database.SaveResult sr : srList) {
if (sr.isSuccess()) {
System.debug('Successfully inserted record with Id ' + sr.getId());
}
else {
for(Database.Error err : sr.getErrors()) {
System.debug('The following error has occurred.');
System.debug(err.getStatusCode() + ': ' + err.getMessage());
System.debug('Fields: ' + err.getFields());
}
}
}