I've created a tool that takes loan data from one system and attempts to insert it into SalesForce. It assigns a Loan Officer by performing a query to find the NMLS #
(which is an indexed field) for a Contact object and setting the Loan_Officer__r
property of the loan object to that id. This worked just fine until about a month ago when I added 2 new required fields to the Contact Object. Here's the main code block (in C#):
foreach (var r in erdbQuery)
{
try
{
Loan__c newLoan = new Loan__c();
newLoan.BorrowerFirstName__c = r.F4000;
newLoan.BorrowerLastName__c = r.F4002;
newLoan.LoanOfficerName__c = r.F317;
newLoan.LoanType__c = r.F1172;
newLoan.LoanRate__c = (double)r.F3;
newLoan.LoanRate__cSpecified = true;
newLoan.LoanAmount__c = (double)r.F2;
newLoan.LoanAmount__cSpecified = true;
newLoan.LoanPurpose__c = r.F19;
newLoan.Address1__c = r.F11;
newLoan.City__c = r.F12;
newLoan.State__c = r.F14;
newLoan.BorrowerEmail__c = r.F1240;
newLoan.Zip__c = r.F15;
newLoan.LoanNumber__c = r.F364;
newLoan.Name = r.F364;
Contact contactReference = new Contact();
contactReference.NMLS__c = Retrieve_LO_ID(r.F3238);
newLoan.Loan_Officer__r = contactReference;
try
{
SaveResult[] results = SfdcBinding.create(new sObject[] { newLoan });
if (results[0].errors != null)
{
add_to_error_log(results[0].errors[0].message, newLoan.LoanNumber__c);
}
}
catch (Exception ex)
{
add_to_error_log(ex.ToString(), newLoan.LoanNumber__c);
}
}
catch (Exception ex)
{
add_to_error_log(ex.ToString(), r.F364);
continue;
}
}
Initially, I got the error message
Required fields are missing: [Bonus_Pay__c, Classification__c] on Loan Removed
So, I had a co-worker back-fill those fields on all records that were missing values. However, even on loans with a Loan Officer that has those fields filled in on their Contact object, I still get the error message. This is very strange, as the Contact object has a number of required fields that are not explicitly set in my code, and I'm not getting errors for them.
Does anyone have any insight on why this might be happening?