• Lauren Hanna 2
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi All, 

I am having some issues with a list button that I want to create on the Opportunity object. Basically, I have a custom object that related to the standard opportunity object. My original goal was to query fields from the related Opportunity and Account object to auto-populate the custom "Escalations" object. 

I continue to get an error saying "invalid or unexpected token". At this point, I have continued to simplify the code to try and find the answer. I would be happy at this point, if someone could tell me the problem with the code below. (Which is much more simplified and doesn't even create anything, it just redirects the user to www.google.com). 
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")}

var OppDetail = sforce.connection.query("SELECT id,Name,AccountId,Account.Name
from Opportunity WHERE id = '{!Opportunity.Id}' LIMIT 1");


var records = OppDetail.getArray("records"); 

var OppName = records[0].name;


if(OppName==null){alert ("PROBLEM")} 


else { 

window.location="www.google.com";
}

Any help would be greatly appreciated. For info purposes, my original code was: 

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")}

var OppDetail = sforce.connection.query("SELECT id,Name,AccountId,Account.Name,
Expiring_Order_Total_del__c,Quote_Amount__c,
Account.Dont_Use_of_Customers_in_District_del__c,Account.Dont_Use_of_schools_in_disctrict_del__c from Opportunity WHERE id ='{!Opportunity.Id}' LIMIT 1");

var records = OppDetail.getArray("records"); 

var oppName = records[0].Name;
var oppid = records[0].id;
var AcctId = records[0].AccountId;
var AcctName = records[0].Account.Name;
var Ordertotal= records[0].Expiring_Order_Total_del__c;
var QuoteAmount= records[0].Quote_Amount__c;
var custindist = records[0].Account.Dont_Use_of_Customers_in_District_del__c;
var schoolsindist= records[0].Account.Dont_Use_of_schools_in_disctrict_del__c;


if(Name==null){alert ("PROBLEM")} 


else { 

window.location="/setup/ui/recordtypeselect.jsp?ent=01Ia00000026qDI&retURL=%2F"+Id+"& 
save_new_url=%2Fa0G%2Fe%3FCF00Na000000Arrzp="+name+
"&CF00Na000000Arrzp_lkid="+id+
"&CF00Na000000ArYAt="+AcctName+
"&CF00Na000000ArYAt_lkid="+AcctId+
"&00Na000000Ars4f="+custindist+
"&00Na000000ArYD9="+schoolsindist+
"&00Na000000ArYD4="+Ordertotal+
"&00Na000000Ars04="+QuoteAmount
}