• ZAC BONNER 1
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hello,
I am trying to create a custom button for the Lead Page Layout to mark a lead as "Unqualified". My code is below; I get no syntax errors but I get the following error message when I click it on a Lead record:

" A problem with the OnClick JavaScript for this button or link was encountered:
Unexpected token catch"


My Code:

{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")} 

{
var url = parent.location.href; 
var updateRecords = []; 
var update_Lead = new sforce.SObject("Lead"); 
update_Lead.Id ="{!Lead.Id}"; 
update_Lead.Status="Unqualified";
updateRecords.push(update_Lead); 

result = sforce.connection.update(updateRecords); 
parent.location.href = url; 
} catch (e) {
alert (e);
}