This is in classic. Also I'm pretty new to SF development.
I'm trying to do something very similar to this question. I've created a custom button, which I want to go to a custom page layout for a Task, and I've associated a Task record type with this page layout. I'm trying to get the javascript to 'pre-select' a record type for the new task, so that it will go to the page layout for that record type.
But when I click on the button, I get the generic 'problem with OnClick Javascript...Unexpected token ;'
Here is my javascript for this custom button:
!REQUIRESCRIPT("/soap/ajax/43.0/connection.js")
var taskObj = new sforce.SObject("Task");
var qr = sforce.connection.query("SELECT Id FROM RecordType WHERE SobjectType ='" + "Task" + "'" + " AND DeveloperName = '" + "My Record Type" + "'");
taskObj.RecordTypeId = qr.records.Id;
window.location = {!Task.Id};
I also tried using $URLFOR but couldn't get that to work either.