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
BangoBango 

ID Undefined

Hello,
I have the following JS code in a an opportunity Detail custom button. My goal:

- Have Sales reps click on a button fron the opportunity that will create a quote record, set the pricebook, and add a quote line item. Everything works except getting the ID of the quote created so I can create the line under it (meaning that I can give it a static ID and it'll work). I highlited what I'm looking to fix in Bold (It's after the = sign). Please help me :)

{!REQUIRESCRIPT('/soap/ajax/34.0/connection.js')} 

var RecID = '{!Opportunity.RecordTypeId}'; 
var pricebookid = "01s60000000AaPr"; 
var newQuote = new sforce.SObject('Quote'); 

var CreateHeader = []; 

if (RecID == "01232000000Q897" || RecID == "012320000005P5G" || RecID == "012600000009XZ6") 

newQuote.RecordTypeId = '01232000000JOUt'; 


newQuote.Name = 'Proposal - {!Today}'; 
newQuote.OpportunityId = '{!Opportunity.Id}'; 
newQuote.Pricebook2Id = pricebookid; 

CreateHeader.push(newQuote) 

result = sforce.connection.create(CreateHeader); 

var CreateLines=[]; 

var linky=new sforce.SObject("QuoteLineItem"); 
linky.QuoteID = result[0].Id
linky.PriceBookEntryId = '01u6000000AQn3TAAT'; 
linky.Quantity = 1; 
linky.UnitPrice = 1; 
linky.Description = 'Add-On - FMA'; 
CreateLines.push(linky); 

result=sforce.connection.create(CreateLines); 


window.location.reload();
Best Answer chosen by Bango
BangoBango
I resolved it, it was the Id, it should be id lol