You need to sign in to do that
Don't have an account?
Soundar Rajan Ponpandi
First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Last Name]: [Last Name]
Dear Friends,
Error : First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Last Name]: [Last Name]
I Got above Error When i try to save Contact records from VF Page. Could You please give me a best Solution.
***************************** Class *****************
Soundar.
Error : First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Last Name]: [Last Name]
I Got above Error When i try to save Contact records from VF Page. Could You please give me a best Solution.
***************************** Class *****************
Public Class Update_KYC{ Public Id CurntRecId{Get;Set;} Private Final Account AccId; Public Account acc{Get;Set;} Public List<Contact> ConList{Get;Set;} Public List<Risk__c> RiskList{Get;Set;} Public Account accrec{GET;SET;} Public Contact accLkp{Get;Set;} public List<Contact> deleteContactList = new List<Contact>(); public List<Risk__c> deleteRiskList = new List<Risk__C>(); Public Update_KYC(Apexpages.StandardController AccController){ AccId = (Account)AccController.GetRecord(); ConList = New List<Contact>(); Contact con = New Contact(); con.AccountId = AccId.Id; ConList.add(con); /*For Risk*/ RiskList = New List<Risk__c>(); Risk__c rsk = New Risk__c(); rsk.Account__C = AccId.Id; RiskList.add(rsk); //accLkp = New Contact(); } /* ADD Contact */ Public Void AddContactRow(){ Contact con = New Contact(); con.AccountId = AccId.Id; ConList.add(con); } Public Void RemoveContactRow(){ Integer indexVal = Integer.valueof(system.currentpagereference().getparameters().get('index')); if(ConList[indexVal - 1].Id != null) deleteContactList.add(ConList[indexVal - 1]); //Remove the contact from the table ConList.remove(indexVal - 1); } Public Void SaveContact(){ System.debug(' ******* Contact List **** |' + ConList); Insert ConList; ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.INFO, + AccId.Name + ' Contacts Added Successfully.'); ApexPages.addMessage(myMsg); ConList.Clear(); ConList = New List<Contact>(); Contact con = New Contact(); con.Account = AccId; ConList.add(con); } /*ADD RIKS*/ Public Void AddRiskRow(){ Risk__C rsk = New Risk__c(); rsk.Account__c = AccId.Id; RiskList.add(rsk); } Public Void RemoveRiskRow(){ Integer indexVal = Integer.valueof(system.currentpagereference().getparameters().get('index1')); if(RiskList[indexVal - 1].Id != null) deleteRiskList.add(RiskList[indexVal - 1]); //Remove the Risk from the table RiskList.remove(indexVal - 1); } Public Void SaveRisk(){ Insert RiskList; ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.INFO, + AccId.Name + ' Risks Added Successfully.'); ApexPages.addMessage(myMsg); RiskList.Clear(); RiskList= New List<Risk__c>(); Risk__c rsk = New Risk__c(); rsk.Account__c = AccId.Id; RiskList.add(rsk); } }************************** VF Page *********************
<apex:page standardController="Account" Extensions="Update_KYC"> <apex:form > <apex:pageBlock title="Update KYC Details" > <apex:pageBlockSection title="{!Account.Name} Details"> <apex:pageBlockSectionItem > <apex:outputLabel value="{!$ObjectType.Account.fields['Name'].label}" /> <apex:outputField value="{!Account.Name}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="{!$ObjectType.Account.fields['Type'].label}" /> <apex:outputField value="{!Account.Type}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="{!$ObjectType.Account.fields['Total_Disbursement_Amount__c'].label}" /> <apex:outputField value="{!Account.Total_Disbursement_Amount__c}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="{!$ObjectType.Account.fields['Total_Commitment_Amount__c'].label}" /> <apex:outputField value="{!Account.Total_Commitment_Amount__c}"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> <apex:pageMessages ></apex:pageMessages> <apex:variable var="rowNumber" value="{!0}"/> <apex:pageblock title="Add Contacts" id="table1"> <div style="overflow: scroll; width: 1200px; height: 280px;"> <apex:pageBlockTable value="{!ConList}" var="con" id="theTable" styleClass="opp-table"> <apex:variable value="{!0}" var="cnt"/> <apex:column headerValue="{!$ObjectType.Contact.fields['FirstName'].label}"> <apex:inputField value="{!con.FirstName}" /> </apex:column> <apex:column headerValue="LastName" > <apex:inputField value="{!con.LastName}" /> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['AccountId'].label}"> <apex:outputField id="Account" value="{!con.AccountId}"/> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['Relationship_ws__c'].label}"> <apex:inputField value="{!con.Relationship_ws__c}"/> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['Constitution_ws__c'].label}"> <apex:inputField value="{!con.Constitution_ws__c}"/> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['Is_Authorised_Signatory_ws__c'].label}"> <apex:inputField value="{!con.Is_Authorised_Signatory_ws__c}"/> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['CIN_ws__c'].label}"> <apex:inputField value="{!con.CIN_ws__c}"/> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['Date_of_Incorporation_ws__c'].label}"> <apex:inputField value="{!con.Date_of_Incorporation_ws__c}" /> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['C_KYC_number_ws__c'].label}"> <apex:inputField value="{!con.C_KYC_number_ws__c}"/> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['PEP_ws__c'].label}"> <apex:inputField value="{!con.PEP_ws__c}"/> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['PAN_Card__c'].label}"> <apex:inputField value="{!con.PAN_Card__c}"/> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['Passport_No_ws__c'].label}"> <apex:inputField value="{!con.Passport_No_ws__c}"/> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['Passport_Expiry_Date_ws__c'].label}"> <apex:inputField value="{!con.Passport_Expiry_Date_ws__c}"/> </apex:column> <apex:column headerValue="{!$ObjectType.Contact.fields['Aadhaar_Number__c'].label}"> <apex:inputField value="{!con.Aadhaar_Number__c}"/> </apex:column> <apex:column headerValue="Address Proof"> <apex:inputField value="{!con.Address_Proof_ws__c }"/> </apex:column> <apex:column > <apex:commandButton value=" Add " action="{!AddContactRow}" rerender="table1,error1" > </apex:commandButton> </apex:column> <apex:column > <apex:commandButton value="Remove" action="{!RemoveContactRow}" rerender="table1,error1" immediate="true" > <apex:param name="index" value="{!cnt}"/> </apex:commandButton> <apex:variable var="cnt" value="{!cnt+1}"/> </apex:column> </apex:pageBlockTable> </div> <apex:pageBlockButtons location="bottom"> <apex:commandButton value=" Save " action="{!SaveContact}" immediate="True" rerender="error1" /> <apex:commandButton value="Cancel" action="{!Cancel}" immediate="True"/> </apex:pageBlockButtons> </apex:pageblock> <apex:pageblock title="Add Risks" id="table2"> <apex:pageBlockTable value="{!RiskList}" var="rsk"> <apex:variable value="{!0}" var="cnt1"/> <apex:column headerValue="Risk Name"> <apex:inputField value="{!rsk.name}"/> </apex:column> <apex:column headerValue="Account"> <apex:outputField id="Account" value="{!rsk.Account__c}"/> </apex:column> <apex:column headerValue="Received Date"> <apex:inputField value="{!rsk.Risk_Categorisation__c}"/> </apex:column> <apex:column headerValue="Received Date"> <apex:inputField value="{!rsk.KYC_Received_Date__c}"/> </apex:column> <apex:column headerValue="Received Date"> <apex:inputField value="{!rsk.KYC_Received_Date__c}"/> </apex:column> <apex:column headerValue="Review Date"> <apex:inputField value="{!rsk.KYC_Review_Date__c }"/> </apex:column> <apex:column headerValue="Categorisation"> <apex:inputField value="{!rsk.Trust_Society__c}"/> </apex:column> <apex:column > <apex:commandButton value=" Add " action="{!AddRiskRow}" rerender="table2,error2" immediate="true"/> </apex:column> <apex:column > <apex:commandButton value="Remove" action="{!RemoveRiskRow}" rerender="table2,error2" immediate="true"> <apex:param name="index1" value="{!cnt1}"/> </apex:commandButton> <apex:variable var="cnt1" value="{!cnt1+1}"/> </apex:column> </apex:pageBlockTable> <apex:pageBlockButtons location="bottom"> <apex:commandButton value=" Save " action="{!SaveRisk}" immediate="True"/> <apex:commandButton value="Cancel" action="{!Cancel}" immediate="True"/> </apex:pageBlockButtons> </apex:pageblock> </apex:form> </apex:page>Regards,
Soundar.
At Line 18, you are assigning only accountId to contact whereas to create a Contact, LastName is a required field.
Make sure to add
Hope it will help!
All Answers
The error is stating that you are not providing the value for a required fields..In this contact: Last name.
I see a method save contact in line 47..you need to add last name to avoid the error.
--
Thanks,
Prashant
At Line 18, you are assigning only accountId to contact whereas to create a Contact, LastName is a required field.
Make sure to add
Hope it will help!