List<id> conIds = new List<id>();
for(Account acc:[SELECT ID,(SELECT id,name FROM Contacts) FROM Account where id =: accountID]){
for(Contact con : acc.Contacts){
conIds.add(con.Id);
}
}
Set<Id> contWithAttachment = new Set<Id>();
Map<Id,Attachment> attachments = new Map<Id,Attachment>([SELECT Id,name,ParentID FROM Attachment WHERE ParentID IN: conIds]);
for(Attachment a : Attachments){
contWithAttachment.add(a.ParentID);
}
List<Contact> conList = [Select Id,Name from Contact where Id IN: contWithAttachment];
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
List<id> conIds = new List<id>();
for(Account acc:[SELECT ID,(SELECT id,name FROM Contacts) FROM Account where id =: accountID]){
for(Contact con : acc.Contacts){
conIds.add(con.Id);
}
}
Set<Id> contWithAttachment = new Set<Id>();
Map<Id,Attachment> attachmentMap = new Map<Id,Attachment>([SELECT Id,name,ParentID FROM Attachment WHERE ParentID IN: conIds]);
for(Attachment a : attachmentMap.values()){
contWithAttachment.add(a.ParentID);
}
List<Contact> conList = [Select Id,Name from Contact where Id IN: contWithAttachment];
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
set<id> conids = new set<id>();
for(contact conlist:[select id from contact where accountid='xxxxxxxxx']){
conids.add(conlist.id);
}
set<id> attachementconids = new set<id>();
for(attachment attachments:[SELECT Id,name,ParentID FROM Attachment WHERE ParentID IN: conids]){
attachementconids.add(attachments.parentid);
}
List<contact> conlist = [select id,name from contact where id=:attachementconids];
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Please use updated code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
try with below code.
If this helps, Please mark it as best answer.
Thanks!!