I have the following query that is supposed to find all the entered data (Contact List) within the range of 2017 and 2016 ( which for some reason returning 2015 back) and see if the Firstname is empty copy the last name and enter it there. but every time I run this inside the
Developer Console -> Debug -> Open Execute Anonymous Window , it stops and gives me error, and says the required field is missing
"Line: 8, Column: 1 System.DmlException: Update failed. First exception on row 82 with id 0031600002B3oy7AAB; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, First name MUST be entered: []"
for(List<Contact> conList :[SELECT Id,FirstName,LastName,Contact_type__c, Commission_Spiff__c FROM Contact Contact WHERE ( CreatedDate < 2017-03-09T14:19:25.000Z OR CreatedDate > 2016-12-01T14:19:25.000Z)])
{
for(Contact ob: conList)
{
if(ob.FirstName == NULL){
ob.FirstName = ob.LastName;
}
}
update conList;
}
Contact Validation Rule
Error Condition Formula ISBLANK(FirstName) Error Message First name MUST be entered