I'm trying to create multiple records of an object called Guarantor__c, a child of Opportunity and Contact, on button click. All of the Guarantor records should relate to the Opportunity on the page where the button is. The records are all of the Contacts of the Opportunity's Account with the Guarantor record type. The SOQL below is pretty straightforward. This runs without an error, but doesn't enter any records. Any ideas?
{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}
var url = parent.location.href;
var updateRecords = [];
var principalContacts = sforce.connection.query("Select Id From Contact where AccountId ='{!Account.Id}' and RecordTypeId ='012A0000000nr4BIAQ'");
var principalContactsArray = principalContacts.getArray("records");
if (principalContactsArray.length < 1){
alert("There are no guarantors for this opportunity. Go back to the Account and enter the guarantors.")
}else{
for (eachPrincipalContact in principalContactsArray){
var newGuarantor = new sforce.SObject("Guarantor__c");
newGuarantor.COntact__ = eachPrincipalContact;
newGuarantor.Opportunity__c ="{!Opportunity.Id}";
updateRecords.push(newGuarantor);
sforce.connection.update(updateRecords);
}
}