You need to sign in to do that
Don't have an account?

for (Database.SaveResult sr : srList)..can somebody expalin the syntax?
for (Database.SaveResult sr : srList)..can somebody expalin the syntax?
what does the 'semi colon' in the bracket mean?
in
Database.SaveResult[] srList = Database.insert(conList, false); // Iterate through each returned result for (Database.SaveResult sr : srList) { if (sr.isSuccess()) { // Operation was successful, so get the ID of the record that was processed System.debug('Successfully inserted contact. Contact ID: ' + sr.getId()); } else { // Operation failed, so get all errors for(Database.Error err : sr.getErrors()) { System.debug('The following error has occurred.'); System.debug(err.getStatusCode() + ': ' + err.getMessage()); System.debug('Contact fields that affected this error: ' + err.getFields()); } }
what does the 'semi colon' in the bracket mean?
in
Database.SaveResult[] srList = Database.insert(conList, false); // Iterate through each returned result for (Database.SaveResult sr : srList) { if (sr.isSuccess()) { // Operation was successful, so get the ID of the record that was processed System.debug('Successfully inserted contact. Contact ID: ' + sr.getId()); } else { // Operation failed, so get all errors for(Database.Error err : sr.getErrors()) { System.debug('The following error has occurred.'); System.debug(err.getStatusCode() + ': ' + err.getMessage()); System.debug('Contact fields that affected this error: ' + err.getFields()); } }
for (each variable named 'sr' in array 'srList) { execute loop block }
Database.SaveResult is the class and data type of variable 'sr', and 'srList' is a list of Database.SaveResult objects (ie. List<Database.SaveResult>).
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_loops.htm
Please mark this answer as correct if it helped you.
All Answers
for (each variable named 'sr' in array 'srList) { execute loop block }
Database.SaveResult is the class and data type of variable 'sr', and 'srList' is a list of Database.SaveResult objects (ie. List<Database.SaveResult>).
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_loops.htm
Please mark this answer as correct if it helped you.