• Yi Tan
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi All

I am a SF administrator and very new to Apex code and VF. I have some questions for my first apex class and VF. Hope you can help me! 

The objective: on case object, I would like to use Account Name value on case as foreign key to query our custom object Account Technical jurisdiciton (ATJ). The relationship between account and ATJ is one to many. There is no direct relationship between case and Account Technical Jurisdiction object. The VF page should be display some fields value from ATJ when user is viewing a case record. 
But when I put my code in, it says " content cannot be displayed: attempt to de-reference a null object", can any one take a look at the codes below and guide me through?  Thank you! 
Apex Code: public with sharing class IGTCaseConJurExtension {
    public Case cs {get;set;}
    public List < IGT_AccountTechnicalJurisdiction__c> Records {get; set;}
    Public IGTCaseConJurExtension (){    Records = [SELECT Account__c,Id,IGT_Technical_Jurisdiction__c,Jurisdiction_Name__c FROM IGT_AccountTechnicalJurisdiction__c WHERE Account__c =: cs.accountId];
    }
}

VF page: 
<apex:page controller="IGTCaseConJurExtension">
<apex:pageBlock title="Account Technical Jurisdiction">
<apex:pageBlockTable value="{!Records}" var="Record"> 
            <apex:column > 
                <apex:facet name="header">Account Name</apex:facet> 
                <apex:outputText value="{!Record.Account__c}"/> 
            </apex:column> 
            <apex:column > 
                <apex:facet name="header">IGT Technical Jurisdiction</apex:facet> 
                <apex:outputText value="{!Record.IGT_Technical_Jurisdiction__c}"/> 
            </apex:column> 
            <apex:column > 
                <apex:facet name="header">Jurisdiction Name</apex:facet> 
                <apex:outputText value="{!Record.Jurisdiction_Name__c}"/> 
            </apex:column> 
        </apex:pageBlockTable> 
</apex:pageBlock>
</apex:page>
Hi All

I am a SF administrator and very new to Apex code and VF. I have some questions for my first apex class and VF. Hope you can help me! 

The objective: on case object, I would like to use Account Name value on case as foreign key to query our custom object Account Technical jurisdiciton (ATJ). The relationship between account and ATJ is one to many. There is no direct relationship between case and Account Technical Jurisdiction object. The VF page should be display some fields value from ATJ when user is viewing a case record. 
But when I put my code in, it says " content cannot be displayed: attempt to de-reference a null object", can any one take a look at the codes below and guide me through?  Thank you! 
Apex Code: public with sharing class IGTCaseConJurExtension {
    public Case cs {get;set;}
    public List < IGT_AccountTechnicalJurisdiction__c> Records {get; set;}
    Public IGTCaseConJurExtension (){    Records = [SELECT Account__c,Id,IGT_Technical_Jurisdiction__c,Jurisdiction_Name__c FROM IGT_AccountTechnicalJurisdiction__c WHERE Account__c =: cs.accountId];
    }
}

VF page: 
<apex:page controller="IGTCaseConJurExtension">
<apex:pageBlock title="Account Technical Jurisdiction">
<apex:pageBlockTable value="{!Records}" var="Record"> 
            <apex:column > 
                <apex:facet name="header">Account Name</apex:facet> 
                <apex:outputText value="{!Record.Account__c}"/> 
            </apex:column> 
            <apex:column > 
                <apex:facet name="header">IGT Technical Jurisdiction</apex:facet> 
                <apex:outputText value="{!Record.IGT_Technical_Jurisdiction__c}"/> 
            </apex:column> 
            <apex:column > 
                <apex:facet name="header">Jurisdiction Name</apex:facet> 
                <apex:outputText value="{!Record.Jurisdiction_Name__c}"/> 
            </apex:column> 
        </apex:pageBlockTable> 
</apex:pageBlock>
</apex:page>