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
petec@i2isyspetec@i2isys 

If statement in a button that sends and email

Hello,

I have a button that works great to send an email template from a case record.
The behavior is Execute JavaScript and the Content Souce is OnClick JavaScript
The code works like this:
location.replace('/email/author/emailauthor.jsp?template_id=00X33000001UT4E&p2_lkid={!Case.ContactId}&p3_lkid={!Case.Id}&p3={!Case.CaseNumber}&p26={!User.Email}&retURL=/{!Case.Id}')

I would like to have the button code check first to see if the person has a certain profile ID.

I tried adding this part that is underlined and didn't get a syntax error, but when I use the button, it fires an invalid or unexpected token error.

IF({!User.ProfileId}<>'00e30000000hQcG',alert('You do not have permission to send survey.'),// location.replace('/email/author/emailauthor.jsp?template_id=00X33000001UT4E&p2_lkid={!Case.ContactId}&p3_lkid={!Case.Id}&p3={!Case.CaseNumber}&p26={!User.Email}&retURL=/{!Case.Id}')
SonamSonam (Salesforce Developers) 
Please use the below format of javascript in the custom button  instead and it should work:
if('{!User.ProfileId}'!=='00e2800000289pV')
{
window.alert("You not allowed");
}
else
{
location.replace('/email/author/emailauthor.jsp?template_id=00X28000001G5Z1&p2_lkid={!Case.ContactId}&p3_lkid={!Case.Id}&p3={!Case.CaseNumber}&p26={!User.Email}&retURL=/{!Case.Id}');
}

Please replace the IDs of profile and template from your ORG.