You need to sign in to do that
Don't have an account?
Stavros McGillicuddy
Quantity not defined
The code below works fine concatenating PriceBook.Entry.Product2.Name on seperate lines of a custom field with a comma at the end of each line.
I need to add Quantity and TotalCost for each Opportunity Product Line item to each line of the custom field and seperate the values with a space hyphen space like this:
PricebookEntryProduct2.Name - Quantity - TotalCost,
PricebookEntryProduct2.Name - Quantity - TotalCost,
PricebookEntryProduct2.Name - Quantity - TotalCost,
PricebookEntryProduct2.Name - Quantity - TotalCost,
When I try to add Quantity and TotalPrice like this, I get a "Quantity not defined" error
I need to add Quantity and TotalCost for each Opportunity Product Line item to each line of the custom field and seperate the values with a space hyphen space like this:
PricebookEntryProduct2.Name - Quantity - TotalCost,
PricebookEntryProduct2.Name - Quantity - TotalCost,
PricebookEntryProduct2.Name - Quantity - TotalCost,
PricebookEntryProduct2.Name - Quantity - TotalCost,
When I try to add Quantity and TotalPrice like this, I get a "Quantity not defined" error
var strProductNames = ''; for(var i=0; i<retriveOpptyLineItems.records.length ; i++){ strProductNames += retriveOpptyLineItems.records[i].PricebookEntry.Product2.Name, Quantity, TotalPrice + ',' + '\n '; }
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")} var record = new sforce.SObject("Opportunity"); record.Id = '{!Opportunity.Id}'; var retriveOpptyLineItems = sforce.connection.query("Select PricebookEntry.Product2.Name, Quantity, TotalPrice From OpportunityLineItem WHERE OpportunityId = '{!Opportunity.Id}' and (NOT Name like '%Discount%')"); var strProductNames = ''; for(var i=0; i<retriveOpptyLineItems.records.length ; i++){ strProductNames += retriveOpptyLineItems.records[i].PricebookEntry.Product2.Name + ',' + '\n '; } //eliminate the last ',' if(strProductNames.length>0){ strProductNames = strProductNames.substring(0,strProductNames.length-1); } record.Sample_Product_Name_1__c = strProductNames; sforce.connection.update([record]); window.location.reload();
I think you need to tell it where to find the Quantity and Total Price fields. Currently you are using them as if they are separately declared variables.