I need to create a New case custom button which will be displayed on the Opportunities object and selects the record type, while also populating other fields on the case page layout.
The easiest way to do this would be to use a URL like
/500/e?cas4={!Opportunity.Account}&CF00N700000030pnt={!Opportunity.Name}&RecordType=012180000004Kle&cas14=New Application
but I also need to assign the case to a queue so it looks like I need to use JavaScript.
I've adapted the below JavaScript code from a Success post but when clicked an error message is displayed "Unexpected token catch" and I can't figure out why?
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
try{
var recToUpdate = new sforce.SObject("Case");
recToUpdate.Id = "{!Case.Id}";
recToUpdate.OwnerId = "00G18000000Ntra";
recToUpdate.Opportunity__c = "{!Opportunity.Id}";
recToUpdate.Account = "{!Opportunity.AccountId}";
recToUpdate.Subject = "New Application";
var result = sforce.connection.update([recToUpdate]);
if(result[0].success == "true"){
location.reload();
}
else{
alert("An Error has Occurred. Error:" + result[0].errors.message);
}
catch(e){
alert("An Error has Occurred. Error:" + e);
}