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
Anita 8Anita 8 

Uncaught [TypeError: Cannot read property 'Product2' of undefined] in lightning design system

Helper
 
setBillingCatCalc : function(cmp, oli) {
        $A.log('running Abstract helper');
        $A.log('billcatcalcs: '+cmp.get("v.billingCatCalcs"));
        $A.log('oli: '+cmp.get("v.oli"));
        
        if (oli.PricebookEntry.Product2  !== undefined && oli.PricebookEntry.Product2.Billing_Category__c !== undefined) {
            cmp.set("v.billingCatCalcs",oli.PricebookEntry.Product2.Billing_Category__c.split(";"));
        }
        var calcBCC = oli.Billing_Category__c+'_'+oli.BillingCalc__c;
        cmp.find("selBCC").set("v.value",calcBCC);
        cmp.set("v.oli",oli);
    }

It's undefined " Product2" . 
How to fix it ??? 
Please , help me to resolve it . 
Thanks you kindly.
Best Answer chosen by Anita 8
Vivek DVivek D
Product2 is not the problem. Your oli list does not have PricebookEntry record that is why it is undefined and the error says there is no product2 for undefined. Change the if condition to check wheather PricebookEntry record is coming or not
if(oli.PricebookEntry !== undefined)

All Answers

Vivek DVivek D
Product2 is not the problem. Your oli list does not have PricebookEntry record that is why it is undefined and the error says there is no product2 for undefined. Change the if condition to check wheather PricebookEntry record is coming or not
if(oli.PricebookEntry !== undefined)
This was selected as the best answer
Anita 8Anita 8

Thanks Vivek . 
 It's ok . but I got other error : Uncaught rerender threw an error in 'markup://aura:iteration' [Error: Unable to format NaN] 
What wrong with it after I push Product2 to OpportunityLineItem ??? 
 

 

Vivek DVivek D
Where you are getting this error ?
Anita 8Anita 8
Thanks for your reply , Vivek .
Now It's work fine .