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
MirembeMirembe 

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
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:inputField value="{!Training2__c.Region__c}"/>
    <apex:inputField value="{!Training2__c.Stichting_Funds_Approval_Date__c}"/>
         </apex:pageBlockSection>
   </apex:pageBlock>
    </apex:form>
</apex:page>
JimRaeJimRae

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.

MirembeMirembe
Hi, The lookup is for a Company Name, and the entire list appears from which to select, but once i select the appropriate name, i get the error message
JimRaeJimRae

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.

 

MirembeMirembe
I get an error when i try to save. The project__c field captures the company name.
JoeyDJoeyD

Bumping an ancient thread. I'm having the same issue.

SteveBowerSteveBower

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.