I am trying to create a custom button on the detail page of the Account object. The button will simply toggle a checkbox field from true to false and vice versa. The code below works for the "IF" condition, but it does nothing for the "ELSE" condition. If I switch the 2, it also works. Does anyone know why my ELSE statement is being ignored when the button is clicked?
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var updateRecords = [];
var a = new sforce.SObject("Account");
a.id ="{!Account.Id}";
if(a.No_Parent_Account__c = "true"){
a.No_Parent_Account__c = "false";
}else{
a.No_Parent_Account__c = "true";
}
newRecords.push(a);
result = sforce.connection.update(updateRecords);
window.location.reload();