I'm trying to create a button that Checks a checkbox field if the button is not checked when it's been clicked. If the checkbox is checked, I want it to uncheck the same box. I've written the code below, but it won't check the box when it's unchecked (it'll only uncheck it if it's checked)
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
var a = new sforce.SObject("Account");
a.Id = "{!Account.Id}";
if (a.Ownership_Requested__c = true) {
a.Ownership_Requested__c = false;
} else {
a.Ownership_Requested__c = true;
}
sforce.connection.update([a]);
location.reload(true);