function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Minky HyunMinky Hyun 

OnClick Javascript - if statement isn't working

I have the following OnClick Javascript code on custom Convert button on a lead page, and I have 2 "if" statements, but only the 2nd one is firing even though both if statement conditinos are met.  Here's the code:

**********

if('{!Lead.Established_Need__c}'=='false') 

alert('You must establish need before converting the lead'); 


if('{!Lead.Status}'!='Qualified') 

alert('Status should be Qualified to convert the Lead'); 


else 

window.location.href='/lead/leadconvert.jsp?retURL={!Lead.Id}&id={!Lead.Id}' 
}

******

Can anyone tell me why?
Alain CabonAlain Cabon
Hi,

if ( {!Lead.Established_Need__c} ) { 
    alert('You must establish need before converting the lead'); 
}

Regards
Minky HyunMinky Hyun
Thanks Alain.  I tried your suggestion, but unfortunately it didn't fix the problem, and the message still doesn't come up for the 1st if statement.  
Alain CabonAlain Cabon
alert( 'need: {!Lead.Established_Need__c}');
console.log('{!Lead.Established_Need__c}');
if ( {!Lead.Established_Need__c} ) { 
    alert('You must establish need before converting the lead'); 
}

What do you see in the popup?
Minky HyunMinky Hyun
Alain, I'm a bit new to the coding so could you please tell me what the whole code would look like with the changes you propose?