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
MitchellbMitchellb 

Problem referencing fields in Account Object

The code below creates this error:

Error: Attribute value in <apex:inputField> must contain only a formula expression that resolves to a single controller variable or method in accountDetail at line 5 column 44

------

<apex:page standardController="Account">
<apex:form>
<apex:pageBlock>
Change Account Name: <p>
<apex:inputField Value="{ !Account.Name}"/> <p/>
<apex:commandButton action="{ !save}" value="Save New Account" />
</apex:pageBlock>
</apex:form>
<apex:detail relatedList="false"/>
<apex:relatedList list="Contacts" />
<apex:relatedList list="Opportunities"/>
</apex:page>

-----

Since 'Name' clearly exists as a field, is there something wrong with the syntax of that line?

 

Also, how can you have a list of all the field names or variable names for a specific object in a window while coding, instead of navigating to the 'Customize' menu?

 

Best Answer chosen by Admin (Salesforce Developers) 
MitchellbMitchellb

This tag was incorrect <p/> as it was using a HTML type syntax and caused the error that confused the compiler.

All Answers

MoggyMoggy
not sure about this but first i would write
<apex:inputField Value="{ !Account.Name}"/>

and then what are these <P/> <p/> for and if there is a function behind wouldn't it be <p> </p>
MitchellbMitchellb

Thank you for the response. I had actually cleaned all of that up and tested again before submitting the post, but did not update that paste. Those items certainly were not helping!

MitchellbMitchellb

This tag was incorrect <p/> as it was using a HTML type syntax and caused the error that confused the compiler.

This was selected as the best answer
Rama Gaikwad 1Rama Gaikwad 1
Hi Moggy,

Mitchellb was write , Error was due to <p>  tag .
Use can use this code.

<apex:page standardController="Account">
    <apex:form>
        <apex:pageBlock>
            Change Account Name: <p>
            <apex:inputField Value="{!Account.Name}"/>
            </p>
            <apex:commandButton action="{!save}" value="Save New Account" />
        </apex:pageBlock>
    </apex:form>
    <apex:detail relatedList="false"/>
    <apex:relatedList list="Contacts" />
    <apex:relatedList list="Opportunities"/>
</apex:page>