I am trying to write a javascript button that only redirects the user if the field Data_Confirmed__c = TRUE, it it is FALSE then they should receive an alert to confirm their data first. I am not getting any errors but it even though the field is FALSE it is still redirecting the user when it shouldn't.
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
if({!Onsite_Review__c.Data_Confirmed__c}=="FALSE") {
alert("Please confirm the data.");
}
else{
window.open('/apex/loop__looplus?sessionId={!$Api.Session_ID}&eid={!Onsite_Review__c.Id}&contactId={!Onsite_Review__c.FSC_ContactId__c}&header=false&sidebar=false&hidecontact=true&tabclass=Custom51Tab&autorun=true&attach=false&ddpIds=a0Fa000000M3fOH');
}
Alternatively if I try to do the opposite and check if the field is != to "TRUE" then it always alerts and never opens the window when it should.
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
if({!Onsite_Review__c.Data_Confirmed__c}!="TRUE") {
alert("Please confirm the data.");
}
else{
window.open('/apex/loop__looplus?sessionId={!$Api.Session_ID}&eid={!Onsite_Review__c.Id}&contactId={!Onsite_Review__c.FSC_ContactId__c}&header=false&sidebar=false&hidecontact=true&tabclass=Custom51Tab&autorun=true&attach=false&ddpIds=a0Fa000000M3fOH');
}