You need to sign in to do that
Don't have an account?

Custom Object Controllers
Hi all,
I'm trying to create a new visualforce page that can accessed via a custom button to display a list of records.
I've tried to create the custom object controller using the code below but get three errors. The custom object is called IT Assets.
API Name: IT_Asset__c
Object Name: IT_Asset
Unknown property 'EmployeeListWithController.IT_Asset__c'
Invalid type: IT_Asset
Illegal conversion from List<IT_Asset__c> to List<IT_Asset>
I've also written a visualforce page to access the records which is currently blank. I want to display just the active records (checkbox).
I'm trying to create a new visualforce page that can accessed via a custom button to display a list of records.
I've tried to create the custom object controller using the code below but get three errors. The custom object is called IT Assets.
API Name: IT_Asset__c
Object Name: IT_Asset
Unknown property 'EmployeeListWithController.IT_Asset__c'
Invalid type: IT_Asset
Illegal conversion from List<IT_Asset__c> to List<IT_Asset>
public class EmployeeListWithController { private String sortOrder = 'Name'; public List<IT_Asset> getIT_Asset() { List<IT_Asset__c> results = Database.query( 'SELECT Id, Device_Type__c, Device_Model__c, Active__c, LastName' + 'FROM IT_Asset__c ' + 'ORDER BY ' + sortOrder + ' ASC ' + 'LIMIT 10' ); return results; } }
I've also written a visualforce page to access the records which is currently blank. I want to display just the active records (checkbox).
<apex:page controller="EmployeeListWithController"> <apex:form> <apex:pageBlock title="Asset List" id="IT_Asset__c"> <!-- IT_Assets List --> <apex:pageBlockTable value="{! IT_Asset__c }" var="it"> <apex:column value="{! it.Name }"/> <apex:column value="{! it.Device_Type__c }"/> <apex:column value="{! it.Device_Model__c }"/> <apex:column value="{! it.Active__c }"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>Can anyone offer some assistance please?
To pass dynamic query values to pageblock table, I recommend checking the sample code here
Let me know if this helps, if it does, please mark this answer as best so that others facing the same issue will find this information useful. Thank you
I've updated the controller but still get this error:
Unknown property 'EmployeeListWithController.IT_Asset__c'
Invalid type: IT_Asset
Illegal conversion from List<IT_Asset__c> to List<IT_Asset>