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
Uttpal chandraUttpal chandra 

Could not resolve field 'Website' from <apex:outputField> value binding '{!con.Website}' in page Abc

Hi All,
Need help on this

Getting Error: Could not resolve field 'Website' from <apex:outputField> value binding '{!con.Website}' in page Abc

1.Controller
public class Abc {
    
    public Dist__c con{get;set;}
    
    public Abc(){
        Id conId = apexpages.currentpage().getparameters().get('id');
        con = [SELECT id,name, (select website,Rating,industry,SLA__c from Accounts__r)from Dist__c WHERE Id=: conId];
    }
}


2.Vf Page
<apex:page controller="Abc">
    <apex:pageBlock> 
        <apex:pageBlockSection columns="1">
           
            <apex:outputField Value="{!con.Website}"/>
            <apex:outputField Value="{!con.Rating}"/>
            <apex:outputField Value="{!con.Industry}"/>
            <apex:outputField Value="{!con.SLA__c}"/>
            
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

 
Madhukar_HeptarcMadhukar_Heptarc
Hi Uttpal,
I have understand the Issue.
Can you please try the below code it may use helps you.
Apex Code :
=========

public class Abc {
    
    public List<Dist__c> con{get;set;}
    
    public Abc(){
        Id conId = 'a080o00002lerchAAA'; // Here, I have taken hardcoded Id But you can Replace ConId from URL. 
       con = [SELECT id,name, (select website,Rating,industry,SLA__c from Accounts__r limit 1) from Dist__c WHERE Id=: conId limit 1];
       system.debug('Dist Data :'+con[0].accounts__r[0].website);
 
    }
}

Visual force Page:
=============
<apex:page controller="Abc">
    <apex:pageBlock> 
        <apex:pageBlockSection columns="1">
            <apex:outputField Value="{!con[0].accounts__r[0].Website}"/>
            <apex:outputField Value="{!con[0].accounts__r[0].Rating}"/>
            <apex:outputField Value="{!con[0].accounts__r[0].Industry}"/>
            <apex:outputField Value="{!con[0].accounts__r[0].SLA__c}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
Please let me know if it helps you.

Thanks & Regards
Madhukar_Heptarc
 
Deepali KulshresthaDeepali Kulshrestha
Hi Uttpal,
Greetings to you!

- Use <apex:pageBlockTable> instead of <apex:pageBlockSection>
<apex:pageBlock title="Details">
    <apex:pageBlockTable border="1" cellpadding="3" cellspacing="0" value="{! mytskLisst }" var="ct" width="100%" >
        <apex:column value="{!con.Website}"/>
        <apex:column value="{!con.Rating}"/>
        <apex:column value="{!con.Industry}"/>
        <apex:column value="{!con.SLA__c}"/>
    </apex:pageBlockTable>
</apex:pageBlock>
    

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

Thanks and Regards,
Deepali Kulshrestha.