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
VIKASH CHAND KUMARVIKASH CHAND KUMAR 

conditional custom button link not working

Hi All, i am trying to write one condition to open Data Import wizard if opportunity is not closed lost. also to throw a message if opportunity is closed lost, but its not working. can you please have a look. also i am using execute on javascript

{! IF(Opportunity.StageName != "Closed Lost", "/lightning/setup/DataManagementDataImporter/home", "XXXXXXXXXXXXXX) }  

also i am trying   below one

if({!Opportunity.StageName=="Closed Lost"}){
    alert("XXXXXXXXXXXXXXXXXX");
}
else{
    window.top.location.href =
        "/lightning/setup/DataManagementDataImporter/home";
}

its not working . 
Best Answer chosen by VIKASH CHAND KUMAR
VinayVinay (Salesforce Developers) 
Hi Vikash,

Try below
if({!NOT(ISPICKVAL(Opportunity.StageName, "Closed Lost"))}){
    alert("XXXXXXXXXXXXXXXXXX");
}
else{
    window.top.location.href =
        "/lightning/setup/DataManagementDataImporter/home";
}

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar