1

I am getting error saying variable SBQQ__LineItems__r does not exist when I try to have values saved in the List with below SOQL on CPQ. What could be the issue here:

List<SBQQ__Quote__c> qte = [SELECT Id, Name, Installation__c, (SELECT Id, Name, SBQQ__ProductName__c FROM SBQQ__LineItems__r ) FROM SBQQ__Quote__c WHERE Name = 'Q-10427'];

LIST<SBQQ__QuoteLine__c> skulist = qte.SBQQ__LineItems__r;
for (SBQQ__QuoteLine__c skuname: skulist) {
    System.debug('SKU Name: '+ skuname.SBQQ__ProductName__c);
}
2

You are trying to reference an attribute SBQQ__LineItems__r on a List<SBQQ__Quote__c>, but this type does not have that attribute. Rather than referencing the collection, you need to reference a single record within it.

List<SBQQ__Quote__c> quotes = [/*query*/];
for (SBQQ__Quote__c quote : quotes)
{
    for (SBQQ_QuoteLine__c lineItem : quote.SBQQ__LineItems__r)
    {
        // now you can manipulate the individual line items
    }
}

Notes how we have SBQQ__Quote__c quote, so you know the quote variable references a singular record. Then we know that we can reference quote.SBQQ__LineItems__r safely using the child relationship name. Informative naming will often help you avoid confusion in your code. I highly recommend you use complete words and pluralize when using collections, as I have demonstrated above.

  • This is great Adrian! Works now. Excellent advice on naming variables. Thank you. – Suraj Timalsina Jul 18 at 0:35

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.