I want to access the Name in the Pricebook2 Object. How to do that in JavaScript? (Salesforce Lightning)

  • u shd be able to access it thru normal JSON Object.Property way.. – Vamsi Krishna Gosu Jul 5 '17 at 7:09
  • @VamsiKrishna As I am new to JavaScript, Can you please give me the correct usage to obtain the name on the Pricebook2 Object which is present in the Array of Objects? – sri Jul 5 '17 at 7:11

Here is the complete syntax:


[] is an array accessor

. is an object property accessor

  • Will this work for Large data sets? Suppose I want to use that value when I am doing some operation like sorting depending on that column what exactly should I do to get all the Pricebook2.Names? Should I loop it and use this? – sri Jul 5 '17 at 7:27
  • Performance is a whole different question.I gave you the basic syntax but you may need to copy these values into a different structure to optimize the way you process your data depending your use case. – POZ Jul 5 '17 at 7:41
  • Thanks. It worked for my use case. Below is the implementation: var total = listOfObjects.length; var i=0; var plistName = []; for(i=0;i<total;i++){ plistName = listOfObjects[i].Pricebook2.Name; plistName.trim(); } console.log(plistName); – sri Jul 5 '17 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.