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
b.gonzalezb.gonzalez 

Problem with OnClick JavaScript button - unexpected end of input

I am recieving the following message when clicking on the custom button: "Problem with OnClick JavaScript button - unexpected end of input".

The issue is with the script written on !Opportunity. Amount. I am trying to write that the opportunity cannot be approved in PMI when the Amount field is BLANK.

Please help! Thanks! Beth
 
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")} 

var strStatus = '{!Opportunity.Opportunity_Status__c}'; 
switch(strStatus) { 
case 'Denied': 
alert('This opportunity cannot be approved because it has been denied.'); 
break; 
case 'Closed': 
case 'Awaiting Claim': 
case 'Claim Submitted': 
case 'Closed Expired': 
case 'Closed Won': 
case 'Closed Lost': 
alert('This opportunity cannot be updated.'); 
break; 
var strAmount = '{!Opportunity.Amount}'; 
switch(strAmount){ 
case 'Null': 
alter('This opportunity cannot be approved because no products are listed.'); 
break; 
default: 
sforce.apex.execute("CMR_DesignWebService", "ApproveToPMIDesign",{OpportunityId:'{!Opportunity.Id}'}); 
alert('Opportunity Approved in PMI system.'); 
window.location = window.location; 
break; 
}

 
Best Answer chosen by b.gonzalez
Dev@Force.ax647Dev@Force.ax647
You have to close first switch statement. Try below code:
 
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")} 

var strStatus = '{!Opportunity.Opportunity_Status__c}'; 
switch(strStatus) { 
case 'Denied': 
alert('This opportunity cannot be approved because it has been denied.'); 
break; 
case 'Closed': 
case 'Awaiting Claim': 
case 'Claim Submitted': 
case 'Closed Expired': 
case 'Closed Won': 
case 'Closed Lost': 
alert('This opportunity cannot be updated.'); 
break; 
}
var strAmount = '{!Opportunity.Amount}'; 
switch(strAmount){ 
case 'Null': 
alter('This opportunity cannot be approved because no products are listed.'); 
break; 
default: 
sforce.apex.execute("CMR_DesignWebService", "ApproveToPMIDesign",{OpportunityId:'{!Opportunity.Id}'}); 
alert('Opportunity Approved in PMI system.'); 
window.location = window.location; 
break; 
}