You need to sign in to do that
Don't have an account?
Correct syntax for new field on VisualForce Page.
Hello,
I'm attempting to add a new field to a VisualForce page but I am receiving this Error Message:
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contract.X18_Digit_Account_Id__c
X18_Digit_Account_Id__c is a custom field on the contract object.
Here's where I'm trying to add it (in bold):
<apex:pageBlockSectionItem >
<apex:outputLabel value="Demo ID" for="DemoIDNumber"/>
<apex:outputText value="{!DemoIDNumber}" id="DemoIDNumber"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Account ID" for="BOAccountID"/>
<apex:outputText value="{!contract.BO_Account__c}" id="BOAccountID"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="18 Digit Account ID" for="X18_Digit_Account_Id__c"/>
<apex:outputText value="{!contract.X18_Digit_Account_Id__c}" id="X18_Digit_Account_Id__c"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Creator ID" for="BO_User_ID__c"/>
<apex:outputText value="{!user.BO_User_ID__c} ({!user.Name})" id="BO_User_ID__c"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Account Name" for="contractAccountName"/>
<apex:outputText value="{!contract.Account.Name}" id="contractAccountName"/>
</apex:pageBlockSectionItem>
I've also attached a screenshot of how the page looks before my change.
I'm a new Developer - can anyone help me sort out the syntax? This is my first alteration to a VF page. I've searched for this error message and have reviewed the resulting posts but am having difficulty applying the info. to my situation.
Thanks,
Julien
I think you should add X18_Digit_Account_Id__c field in your controller. Do you have custom controller for this page or just use standard ?(check apex:page element)
All Answers
I think you should add X18_Digit_Account_Id__c field in your controller. Do you have custom controller for this page or just use standard ?(check apex:page element)
Thanks for your response. We do have an Apex Class that the page refers to. Here's the first line from the VF Page:
<apex:page controller="ProvisioningInfo"
Is that what you mean?
So you need to find piece of code with SOQL in ProvisioningInfo controller where your contract is queried and add X18_Digit_Account_Id__c field there.
Or if you can past ProvisioningInfo's code here and I'll try to help you more.
https://gist.github.com/jcamp6/f5888f0764f9c7d4fa26
Just add X18_Digit_Account_Id__c field there and check.
Id,
Account.Name,
X18_Digit_Account_Id__c
Account.Phone,
Allow_Share__c,
Pricing_Type__c,
contractList = [SELECT
Id,
Account.Name,
X18_Digit_Account_Id__c,
Account.Phone,
Allow_Share__c,
Pricing_Type__c,
Error: ProvisioningInfo Compile Error: Test methods must be in test classes at line 860 column 28.
I'm looking, too.
The VF Page is now working (once I removed lines 860 - on (the test code) and the field is there. I attempted to create a new Apex Class for the test but hit a wall there but I can work with someone internally to get that resolved and not take up anymore of your time.
Thanks again!!
Best,
Julien