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
Admin User 3585Admin User 3585 

SOBJECT ROW WAS RETRIEVED VIA SOQL

Hi,

any one can suggest.

<apex:repeat value="{!lstQLI}" var="QLI"> <div style="page-break-inside:avoid; margin-top:25px;"> <p style="font-weight:bold; font-size:1em; text-decoration:bold;">{!count}. {!if(QLI.Product_Name_in_Offer__c != null, QLI.Product_Name_in_Offer__c , QLI.Name)}</p> <p style="text-indent:1em"> <apex:PageBlock rendered="{!if(!CONTAINS(QLI.Vendor_Material__r.Product_Spec__c,'xxxxxxxx') ,if(mapIdLstTS[QLI.Id] == NULL, FALSE, TRUE),FALSE)}"> <apex:PageBlockTable cellspacing="5" var="TS" value="{!mapIdLstTS[QLI.Id]}" columns="2" rendered="{!if(mapIdLstTS[QLI.Id] == NULL, FALSE, TRUE)}"> <apex:column width="25%" value="{!TS.Label__c}"/> <apex:column width="5%" /> <apex:column value="{!TS.Value__c}"/> </apex:PageBlockTable> </apex:PageBlock> <apex:PageBlock rendered="{!if(CONTAINS(QLI.Product__r.Name,'XXXXXXX') ,TRUE,FALSE)}"> <apex:outputText value="{!QLI.Vendor_Material__r.Product_Spec__c}" escape="False"/> </apex:PageBlock> </p>


ERROR MESSAGE IS : 
SObject row was retrieved via SOQL without querying the requested field: QuoteLineItem__c.Vendor_Material__r 
Yogesh Malbhage 18Yogesh Malbhage 18
Have you queried QuoteLineItem__c.Vendor_Material__r field in a soql query in apex? 
Ajay K DubediAjay K Dubedi
Hi,

You have used the 'Vendor_Material__c' data without querying it in apex controller of VfPage.
You have queried 'lstQLI' list in your VF page Controller. but you have have not queried 'Vendor_Material__r' data in the query. if you alse query the 'Vendor_Material__r' data using inner query. you will not see this error.

You can use below code to remove this error.

lstQLI = [SELECT RequiredParentFieldnames,(SELECT RequiredChildfieldvalues FROM ChildObject) FROM ParentObject];
You can replace 'ChildObject', 'ParentObject', 'RequiredParentFieldnames','RequiredChildfieldvalues' according to the requirement in the query.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com