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
StaciStaci 

javascript button getting IF is not defined

I have a custom Clone button with the following:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 

alert("----"+'{!$UserRole.Name}'+"-----"+'{!User.Account_Name_Dealer_Text__c}'+"-------"); 
IF(CONTAINS($UserRole.Name,User.Account_Name_Dealer_Text__c),window.parent.location.href="/{!Case.Id}/e?clone=1&retURL=/{!Case.Id}",alert("You are not a contact for this dealer."))

I'm trying to see if account name is contained in the role of the logged in user.  I'm getting IF is not defined when the button is clicked.  The logged in user and account do match in my testing scenerio.
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Hi Staci,

You can't use IF ELSE in javascript like that. You need to write it like that way you write in code.
if(){
{
else{
}