I am trying to create a custom button that works for multiple different objects to all come back to my Data_Feasibility_Report__c custom object. I was trying to create the button to pull from the Lead standard object but I keep gettting an error that I am not sure how to fix. Any help would be appreciated. Here is the code that I am trying to write. I am trying to pull the Name from the Lead and the record type as well as a couple custom fields. When I go test the button I get "Unexpected Identifier".
{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")}
var acct = new sforce.SObject(Data_Feasibility_Report__c);
acct.name = 'New Account';
acct.Related_To__c = 'Lead';
acct.Related_Lead__c = {!Lead.Name};
var result = sforce.connection.create([acct]);
if(result[0].getBoolean(“success”)){
window.location = “/” + result[0].id + “/e”;
}else{
alert(‘Could not create record ‘+result);
}
I tried a different way as well to see if I was going the wrong direction and I was getting "Invalid or unexpected token"
{!REQUIRESCRIPT('/soap/ajax/35.0/connection.js')}
getDate = function(dateObj){
var day = dateObj.getDay() < 9 ? '0'+dateObj.getDay() : dateObj.getDay();
var month = dateObj.getMonth() < 9 ? '0'+dateObj.getMonth() : dateObj.getMonth();
return dateObj.getFullYear()+'-'+month+'-'+day;
}
var oppty = new sforce.SObject('Data_Feasibility_Report__c');
oppty.Related_Lead__c = '{!Lead.Name};
oppty.Related_To__c = 'Lead';
RecordType=0125C00000005jd;
result = sforce.connection.create([oppty]);
if(result[0].success == 'true'){
alert('An New Data Feasibility Report with Name - ' + oppty.Name + ' was Created Successfully.');
}
Anyone know what I am doing wrong?