You need to sign in to do that
Don't have an account?
Sonam Patil
Visualforce Exception Error
Hi,
In the below, there are two pageblock, in first block is to display the list of Account and second block is to insert the account.And inserted account in second block should be dynamicaly displayed in 1st block. when I click on Save button it's showing the below error.
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Account Name]: [Account Name]
Please can anyone help me to solve this error.
<apex:page controller="multiAccountInsert">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!accts}" var="a" reRender="display" >
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Industry}"/>
<apex:column value="{!a.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockButtons location="top" >
<apex:commandButton value="Save" action="{!Save}" id="display"/>
</apex:pageBlockButtons>
<apex:pageblocksection >
Enter Name: <apex:inputText value="{!at.Name}"/>
</apex:pageblocksection>
</apex:pageBlock>
</apex:form>
</apex:page>
------------------------------------------
public class multiAccountInsert{
public Account at { get; set; }
public PageReference Save() {
at = new Account();
insert at;
return null;
}
public List<Account> accts {get; set;}
public multiAccountInsert(){
accts = new List<Account>();
accts = [Select id, Name, Industry, Phone from Account];
}
}
In the below, there are two pageblock, in first block is to display the list of Account and second block is to insert the account.And inserted account in second block should be dynamicaly displayed in 1st block. when I click on Save button it's showing the below error.
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Account Name]: [Account Name]
Please can anyone help me to solve this error.
<apex:page controller="multiAccountInsert">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!accts}" var="a" reRender="display" >
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Industry}"/>
<apex:column value="{!a.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockButtons location="top" >
<apex:commandButton value="Save" action="{!Save}" id="display"/>
</apex:pageBlockButtons>
<apex:pageblocksection >
Enter Name: <apex:inputText value="{!at.Name}"/>
</apex:pageblocksection>
</apex:pageBlock>
</apex:form>
</apex:page>
------------------------------------------
public class multiAccountInsert{
public Account at { get; set; }
public PageReference Save() {
at = new Account();
insert at;
return null;
}
public List<Account> accts {get; set;}
public multiAccountInsert(){
accts = new List<Account>();
accts = [Select id, Name, Industry, Phone from Account];
}
}
In your controller you did't assign Account name from page while insert. its Required field for Account Insert.
use below controller and page.
Controller:
page:
Hope this will work.
mark Best ASNWER if its works for you.
Thanks
karthik
All Answers
In your controller you did't assign Account name from page while insert. its Required field for Account Insert.
use below controller and page.
Controller:
page:
Hope this will work.
mark Best ASNWER if its works for you.
Thanks
karthik