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
DritterDritter 

Custom Link using OnClick JavaScript

We have an umlimited edition and I'm trying to create a new record called a "support ticket" off of a user's record (custom link). Below is the script, but when I click the button I get the following error:

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

-------Script-------

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
   
var st = new sforce.SObject('Support_Ticket__c');

    st.RecordType = 'Magic Ticket';
    st.On_Behalf_Of__c = {!User.Id};

var result = sforce.connection.create([st]);
    if(result[0].getBoolean("success")){
       window.location = "/" + result[0].id + "/e";
          }else{
             alert('Could not create record '+result);
}
DritterDritter
I updated it. I took out the record type. All I need to populate the user on the support ticket (new record). Any help?

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
   
var st = new sforce.SObject('Support_Ticket__c');

    st.On_Behalf_Of__c = User.id;

var result = sforce.connection.create([st]);
    if(result[0].getBoolean("success")){
       window.location = "/" + result[0].id + "/e";
          }else{
             alert('Could not create record '+result);
}