You need to sign in to do that
Don't have an account?
Bango
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();
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
Bango
I resolved it, it was the Id, it should be id lol