You need to sign in to do that
Don't have an account?
shekhar 46
i Want to insert account record when VFP get load
Want to insert account record when VFP get load
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Hello Shekar,
You can try this:
Controller:-
public class AccountContactController{
public Account acc{get;set;}
public List<Contact> cont{get;set;}
public AccountContactController(){
acc = new Account();
cont = new List<Contact>();
AddRow();
AddRow();
AddRow();
}
public void AddRow(){
cont.add(new Contact());
}
public void save(){
if(acc.name != null){
insert acc;
List<contact> con = new List<contact>();
for(Contact c : cont){
c.AccountId = acc.id;
con.add(c);
}
if(con != null){
insert con;
}
}
}}
VFPage:-
<apex:page controller="AccountContactController">
<apex:form >
<apex:pageBlock >
<apex:pageblocksection columns="2">
<apex:inputField value="{!acc.name}"/>
<apex:inputField value="{!acc.phone}"/>
<apex:inputField value="{!acc.website}"/>
<apex:inputField value="{!acc.Sic}"/>
</apex:pageblocksection>
<apex:pageBlockSection columns="1">
<apex:pageBlockTable value="{!cont}" var="contacts">
<apex:column headerValue="First Name">
<apex:inputField value="{!contacts.firstname}"/>
</apex:column>
<apex:column headerValue="Last Name">
<apex:inputField value="{!contacts.lastname}"/>
</apex:column>
<apex:column headerValue="Email">
<apex:inputField value="{!contacts.email}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Add Row" action="{!AddRow}" immediate="true"/>
</apex:pageBlockButtons>
</apex:pageBlock>
We were facing same in one of our project (https://menupriceshub.com/) and we resolved with this.
Please let us know if you need more assistance.
Thanks,
Jessica
To open a record, click the record.
From Setup, click Edit Object.
Click Lightning Record Pages and then click New.
Select Record Page, and click Next.
Enter a label.
In Object, select your object and then click Next.
https://www.tigerishome.org/
Create a Custom Object Record Page
From the App Launcher, find and select your custom object.
To open a record, click the record.
From Setup, click Edit Object. (https://www.checkmyrota.org/)
Click Lightning Record Pages and then click New.
Select Record Page, and click Next.
Enter a label.
In Object, select your object and then click Next.