+ Start a Discussion
Brian FerrariBrian Ferrari 

Custom Button Using OnClick Java Script

I created a custom clone button.  I want to only permit clone if certain fields are empty.  In the script below I am just checking one field until I get this to work.  I have never used the OnClick option in a custom button and I am not familiar with Java Script.  The following script runs but always produces the error.  I can't get the cloned case to appear.   Any ideas?  I may be approaching this totally wrong.

Development_PM__c is a custom lookup field.  If it is blank I want to proceed cloning.  If populated, throw the alert.

if('{!Case.Development_PM }'  ==  '  ' || {!Case.Developer__c}  <> ' '){
  location.replace('{!Case.Id}/e?clone=1&retURL=%2F{!Case.Id}');
}
else{
 alert('Sorry!. Can't clone a case that has PM and/or development fields populated.');
}
Brian FerrariBrian Ferrari
My bad...I have taken out the check on Case.Developer__c

if('{!Case.Development_PM }'  ==  '  ' ){
  location.replace('{!Case.Id}/e?clone=1&retURL=%2F{!Case.Id}');
}
else{
 alert('Sorry!. Can't clone a case that has PM and/or development fields populated.');
}