You need to sign in to do that
Don't have an account?

How to query for Task and their Task relations contacts?
Hi guys,
I am stuck on this problem where I want to loop through task id and their task relation contacts ids. I am not sure how to do it.
Thank you!
I am stuck on this problem where I want to loop through task id and their task relation contacts ids. I am not sure how to do it.
List<Contact> relatedContacts = [select id,Last_Activity_Subject__c, (select id,Subject from Tasks Order By ActivityDate DESC LIMIT 1) from Contact where id in:ContactIds]; for (Contact relatedContact : relatedContacts) { relatedContact.Last_Activity_Subject__c = relatedContact.Tasks[0].Subject; } update relatedContacts;this code I have it does not update properly for the task relation names.
Thank you!
You can use the below code.
You can change the code accordingly.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com