You need to sign in to do that
Don't have an account?
Aryan Jha
contact is not made in account
public class AccountWithContacts {
public static void Accountwithcontactsassociated()
{
Set<Id>accId=new Set<Id>();
List<Contact>contacts=new List<Contact>();
List<Account>accList=[SELECT Id,Name,Phone,(SELECT firstname,Phone FROM Contacts) FROM Account WHERE Id=:accID];
for(Account acc:accList)
{
for(Contact con:acc.contacts)
{
con.AccountId=acc.Id;
con.FirstName=acc.Name;
con.Phone=acc.phone;
contacts.add(con);
}
}
update contacts;
}
}
public static void Accountwithcontactsassociated()
{
Set<Id>accId=new Set<Id>();
List<Contact>contacts=new List<Contact>();
List<Account>accList=[SELECT Id,Name,Phone,(SELECT firstname,Phone FROM Contacts) FROM Account WHERE Id=:accID];
for(Account acc:accList)
{
for(Contact con:acc.contacts)
{
con.AccountId=acc.Id;
con.FirstName=acc.Name;
con.Phone=acc.phone;
contacts.add(con);
}
}
update contacts;
}
}
How you are calling this method?
accID which you are using in where clause doesn't seems to have any data?
Thanks!
Attaching some closest references
Trigger
https://developer.salesforce.com/forums/?id=9060G000000IBeVQAW
Batch
https://www.sfdcamplified.com/2019/04/update-account-and-related-contacts-using-batch-and-scheduled-apex.html
Thanks!