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
andyaldis1.3969086903835708E12andyaldis1.3969086903835708E12 

Creating a vf form from a custom object

I am looking for a little help I am pretty much brand new to VF and other than training I have never actually done anything functional in it.  I am trying to create a form from a custom object but keep getting the error Coul not resolvve the entity from <apex:inputField> value binding '{!Initial_Investment_Costs__c}", <apex:inputField> can only be sused with SObjects, or objects that are Visualforce field component resolvable.  But I cannot figure out what is the problem.  My VF page is below.

<apex:page standardController="CapEx_OpEx_Initial_Investment_Costs__c">
    <apex:form>
        <apex:pageBlock title="Add Initial Investment Costs">
            <apex:inputField value="{! Initial_Investment_Costs__c}"/>
            <apex:inputField value="{! If_Other_Please_Specify__c}"/>
            <apex:inputField value="{! Year_0__c}"/>
            <apex:inputField value="{! Year_1__c}"/>
            <apex:inputField value="{! Year_2__c}"/>
            <apex:inputField value="{! Year_3__c}"/>
            <apex:inputField value="{! Additional_Notes__c}"/>
             
            <apex:pageBlockButtons>
                <apex:commandButton action="{! save }" value="Save" />  
                <apex:commandButton action="{! save&New }" value="Save & New" />   
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Shivani DesaiShivani Desai
You need to append the fields to the custom object name. For eg. {!CapEx_OpEx_Initial_Investment_Costs__c.If_Other_Please_Specify__c}.

If this helps you solve your problem, please like it.
andyaldis1.3969086903835708E12andyaldis1.3969086903835708E12
It did something but now I am just getting a new error message.

User-added image
Shivani DesaiShivani Desai
Can you copy paste the error message? Am unable to view it clearly.
Pankaj_GanwaniPankaj_Ganwani
Hi Shivani and andyaldis1.3969086903835708E12,

I have just tried the above code for Account standardcontroller and found that 'Save & New' action does not support with standard controllers. Please remove <apex:commandButton action="{! save&New }" value="Save & New" /> statement from vf code and try to save it.

Thanks,
Pankaj
ManojjenaManojjena
Hi andyaldis,
,
Pankaj is right there is no such method as save and new  in standard controller you have to do simple customisation to achive this .Please use below code it will solve your problem  .Onclick of save it will redirect to the record detail page ,but save and new will create record and allow you to create one more record .
 
<apex:page standardController="CapEx_OpEx_Initial_Investment_Costs__c" extensions="DemoClass">
    <apex:form>
        <apex:pageBlock title="Add Initial Investment Costs">
            <apex:inputField value="{! CapEx_OpEx_Initial_Investment_Costs__c.Initial_Investment_Costs__c}"/>
            <apex:inputField value="{! CapEx_OpEx_Initial_Investment_Costs__c.If_Other_Please_Specify__c}"/>
            <apex:inputField value="{! CapEx_OpEx_Initial_Investment_Costs__c.Year_0__c}"/>
            <apex:inputField value="{! CapEx_OpEx_Initial_Investment_Costs__c.Year_1__c}"/>
            <apex:inputField value="{! CapEx_OpEx_Initial_Investment_Costs__c.Year_2__c}"/>
            <apex:inputField value="{! CapEx_OpEx_Initial_Investment_Costs__c.Year_3__c}"/>
            <apex:inputField value="{!CapEx_OpEx_Initial_Investment_Costs__c.Additional_Notes__c}"/>
            <apex:pageBlockButtons>
                <apex:commandButton action="{! save }" value="Save" />  
                 <apex:commandButton action="{!doSave}" value="Save & New" oncomplete="document.location.reload(true)" />   
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>


public class DemoClass{
    public Candidate_Task__c can{get;set;}
	public DemoClass(ApexPages.StandradController scon){
		this.can = (Candidate_Task__c)scon.getRecord();
	 }
	 public void doSave(){
	  try{
	    Insert can;
		}Catch(DmlException de){
		  System.debug(de);
		}
	 }
}