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
Joe HayesJoe Hayes 

Invalid or unexpected token on JS button

I have ran the below code through a couple of JS validators and everything seems to be ok. Not sure where I am going wrong with this one. I get an unexpected or invalid token error. It is script for a javascript button on the opportunity page.
 
{!REQUIRESCRIPT("/soap/ajax/42.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/42.0/apex.js")}

var location = "{!Opportunity.Location_for_Training__c}";

if(location.length > 0) {

var opp = new sforce.SObject("Opportunity");
opp.Id = "{!Opportunity.Id}";
opp.InHouseDateRequestChkBox__c = true;

var result = sforce.connection.update([opp]); 
if(result[0].success == 'true') 
{ 
alert("Dates requested!");

var t = new sforce.SObject("Task");
var today = new Date();
t.Subject = "In-house Dates Requested";
t.Status = "Completed";
t.OwnerId = "{!User.Id}";
t.ActivityDate = today;
t.WhatId = opp.Id;
t.recordTypeId = "012D0000000YTTW";

opp.InHouseDateRequestChkBox__c = false;

result = sforce.connection.create([t]);
result = sforce.connection.update([opp]);

window.location.reload();
} else 
  { 
   alert("Sending failed");
  }

} else 
  {
   alert("Please add a location for training before requesting dates");
  }