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
praveen murugesanpraveen murugesan 

Unknown property 'VisualforceArrayList.name'

Hello All,

I cant save the VF page code it is showing this error Unknown property 'VisualforceArrayList.name'.

Previously ie., two days before the code was saved and worked correctly. But today I was tried to save the same code but I cant save. Its because of related object's fields. Any suggestions.?

My page code:

<apex:pageBlockTable value="{!emplist}" var="emp" >       
        <apex:column headerValue="Name">                     
         <apex:outputText value="{!emp.User__r.name}" />          
        </apex:column>
</apex:pageBlockTable>

Controller Code:

List<Employee__c> emplist = [select ID,Name,user__c,User__r.name from Employee__c ];

Fields:

User__c is a custom filed in Employee__c which related to user object.

Thanks.


hitesh90hitesh90
Hello Praveen,

You have created two way relationship with same name so this issue has been occurs.

Refer below link:
http://www.tgerm.com/2013/06/adding-new-fields-can-break-existing.html

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
Email :- hiteshpatel.aspl@gmail.com
My Blog:- http://mrjavascript.blogspot.in/
ShashForceShashForce
Hi Praveen,

In your apex:outputText tag, you are using 'emp.user__r.name'. The 'emp', which is a list, does not have a name property. It is the list item which has that property. You need to reference the name that refers to the list item, and not the list itself.

Please try it out and if this help, please mark this as a best answer so that it will be useful for others who have a similar question.

Thanks,
Shashank
praveen murugesanpraveen murugesan
@Rockzz,

Hi I have changed the var name which i have used as list variable eventhough I cant save the code.

@hitesh90,

Here I have used custom controller with query. The query will return the all the values which I have used in page.

@Shashank_SFDC,

If I understood your suggestion correctly means in that query I have queried user__r.name, user__c which I have used to display in the page. If I am wrong pls explain me bit briefly.

Thanks
praveen murugesanpraveen murugesan
Hi All,

One more important thing 2 days before same code worked perfectly. Today I cant save the same code. (I was tried to save the same code with adding space). 

And if i tried to save my code with emp.user__c only means it is getting saved but not with emp.user__r.name

Thanks
ShashForceShashForce
Hi Praveen,

As suggested by @hitesh90, please check for ambiguous relationships, i.e., 2 relationships having the same name.

Thanks,
Shashank
Vinit_KumarVinit_Kumar
You need to debug in your org,In my org it is working fine :-

My VF :-

<apex:page standardController="Client__c" extensions="TestController">

<apex:form>
<apex:pageblock>
<apex:pageBlockTable value="{!cllist}" var="emp" >      
        <apex:column headerValue="Name">                    
         <apex:outputText value="{!emp.Contact__r.name}" />         
        </apex:column>
</apex:pageBlockTable>
</apex:pageblock>:-
</apex:form>
</apex:page>

My Controller :-

public class TestController
{
   
        public List<Client__c> clList{get;set;}
       
    public TestController(ApexPages.StandardController controller) {
        clList = [select ID,Name,Contact__c,Contact__r.name from Client__c where id='a0290000007aSE9'];
    }


   
}

praveen murugesanpraveen murugesan
Hi,

For me all the objects fields where working but user objects fields only not accessible. 

Eg,

My page code:

<apex:pageBlockTable value="{!emplist}" var="emp" >      
        <apex:column headerValue="Name">                    
         <apex:outputText value="{!emp.User__r.name}" />         // Here only i am getting error Unknown property 'VisualforceArrayList.name'.
        </apex:column>
          <apex:column headerValue="User ID">                  
         <apex:outputText value="{!emp.user__c}" />        //It is working fine
        </apex:column>
        <apex:column headerValue="Dept">                   
         <apex:outputText value="{!emp.Department__r.name}" />         //It is working fine
        </apex:column>
</apex:pageBlockTable>

Controller Code:

List<Employee__c> emplist = [select ID,Name,user__c,User__r.name, Department__r.name from Employee__c ];

Note: 

Employee__c has a lookup realation with Department__c and User.  So, If I use user__c or Department__r.name it is displaying fine. But if I use User object's fields means it is showing an error.
Vinit_KumarVinit_Kumar
I updated my code to use User object and that is also working fine.

VF Page :-

<apex:page standardController="Client__c" extensions="TestController">

<apex:form >
<apex:pageblock >
<apex:pageBlockTable value="{!cllist}" var="emp" >      
        <apex:column headerValue="Name">                    
         <apex:outputText value="{!emp.Contact__r.name}" />  
         <apex:outputText value="{!emp.User__r.name}" />       
        </apex:column>
</apex:pageBlockTable>
</apex:pageblock>
</apex:form>
</apex:page>

Apex :-

public class TestController
{
   
        public List<Client__c> clList{get;set;}
       
    public TestController(ApexPages.StandardController controller) {
        clList = [select ID,Name,Contact__c,Contact__r.name,User__r.name from Client__c where id='a0290000007aSE9'];
    }


   
}
praveen murugesanpraveen murugesan
Vinit,

I agree with you.

For me also it is working in my personal org. But not in this org where I need to show.

Thanks.
Vinit_KumarVinit_Kumar
Then,its simple something not going good in ur org where it is failing.You need to check configuration in that particular org.
praveen murugesanpraveen murugesan
I have logged in as System Administrator and using std fields in User Object. Do you have any idea abt where I need to check.

Thanks.
praveen murugesanpraveen murugesan
Hi All,

I couldn't found the issue. Please let me know if anybody found the reason. 

As of now I have acheived this by querying directly from the user object. I have queired and displayed in VF page.ser

Code: 

public user us {get;set;}

us = [select id, name from user];

Page:

<apex:outputtext value = "{!us.name}">
<apex:outputtext value = "{!us.id}">

Thanks.