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
YukinonYukinon 

Unknown Property Error VF Component

I keep on getting Unknown Property Error. Any tips on how can I solve it?

Controller:
public class ActiveOpportunityLineItems {
    public List<OpportunityLineItem> lineItems {get; set;}
    	
    public List<OpportunityLineItem> findActiveItems() {
       lineItems = [SELECT Name From OpportunityLineItem WHERE Active__c = TRUE];
       return lineItems;   
    }
    
}

Component:
<apex:component controller="ActiveOpportunityLineItems" access="global">
	<apex:pageBlock title="Opportunity Line items">
       <apex:pageBlockTable value="{!findActiveItems.Opportunity}" var="opportunity">
         <apex:column value="{!opportunity.Name}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:component>
Error:
Unknown property 'ActiveOpportunityLineItems.findActiveItems'


 
Maciej Król 28Maciej Król 28
it seems you should mark your method with @AuraEnabled
AnkaiahAnkaiah (Salesforce Developers) 
Hi Angel,

you need to replace the "{!findActiveItems.Opportunity}" with "{!lineItems}" in the componenet.

If this helps, please mark it as best answer.

thanks!!
Balamy saviourBalamy saviour
It's seems good you know cps test (https://cps-test.onl/)
mukesh guptamukesh gupta
Hi Angel,

Please use below code:-
 
public class ActiveOpportunityLineItems {
    public List<OpportunityLineItem> lineItems {get; set;}
    
@AuraEnabled	
    public List<OpportunityLineItem> findActiveItems() {
       lineItems = [SELECT Name From OpportunityLineItem WHERE Active__c = TRUE];
       return lineItems;   
    }
    
}
 
<apex:component controller="ActiveOpportunityLineItems" access="global">
	<apex:pageBlock title="Opportunity Line items">
       <apex:pageBlockTable value="{!lineItems}" var="oli">
         <apex:column value="{!oli.Name}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:component>

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh