You need to sign in to do that
Don't have an account?
Mirembe
Unable to populate required field on visualforce page
Hi,
I created a visualforce page( on a custom object), to overide my standard "New" Button.
I used the input field component to input data into 2 required lookup fields but every time i type data into these fields i get an error message
<apex:inputField value="{!Training2__c.Region__c}"/>
<apex:inputField value="{!Training2__c.Stichting_Funds_Approval_Date__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Error: Required fields are missing: [Project__c, Training_Grant__c],
my code looks like this;
<apex:page standardController="Training2__c">
<apex:form >
<apex:pageBlock title="Training Edit" mode="edit">
<apex:commandButton action="{!save}" value="Save">
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:commandButton>
</apex:pageBlock>
</apex:form>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Project Information" columns="2">
<apex:inputField value="{!Training2__c.Project__c}"/>
<apex:inputField value="{!Training2__c.Training_Grant__c}"/>
<apex:inputField value="{!Training2__c.Current_Balance__c}"/>
<apex:inputField value="{!Training2__c.Total_TE_fee_Balance__c}"/>
<apex:inputField value="{!Training2__c.TE_Balance__c}"/>
<apex:form >
<apex:pageBlock title="Training Edit" mode="edit">
<apex:commandButton action="{!save}" value="Save">
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:commandButton>
</apex:pageBlock>
</apex:form>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Project Information" columns="2">
<apex:inputField value="{!Training2__c.Project__c}"/>
<apex:inputField value="{!Training2__c.Training_Grant__c}"/>
<apex:inputField value="{!Training2__c.Current_Balance__c}"/>
<apex:inputField value="{!Training2__c.Total_TE_fee_Balance__c}"/>
<apex:inputField value="{!Training2__c.TE_Balance__c}"/>
<apex:inputField value="{!Training2__c.Region__c}"/>
<apex:inputField value="{!Training2__c.Stichting_Funds_Approval_Date__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
When your page generates, is it showing these lookup fields correctly? That is, as lookup fields?
Are you looking up a value?
Remember that a lookup will show the text version, but place the ID of the reference object into the new record.
Are you getting the error when you try to save, or when you enter the data? Could you have other required fields on the custom object that you are not completing as well? I don't see anything that even looks like a company name field in your page code.
Bumping an ancient thread. I'm having the same issue.
Why do you have two Forms? Change it to be one Form that spans the Buttons *and* the data fields and see if that addresses your problem. Best, Steve.