
답변 3개

Hi Palukuru,I think you are trying to create contacts for some existing accounts. You can do that by -
Please accept my solution as Best Answer if my reply is helpful.//Fetch the existing Account
List<Account> accounts = [SELECT ID FROM Account Where <PUT YOUR UNIQUE IDENTIFIER TO FETCH THE EXISTING ACCOUNT>];
List<Contact> allContacts = new List<Contact>();
if(accounts.size()>0){
Contact singleContact = new Contact();
singleContact.FirstName = 'John';
singleContact.LastName = 'Miller';
singleContact.AccountID = accounts.get(0).Id;
allContacts.add(singleContact);
}
if(allContacts.size() > 0){
insert allContacts;
}