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

How to get Name from Task Instead of WhoId?
Hi guys,
I need a help here.. I am trying to extract Name from Tasks but I got the ID instead. Is there any way we could get the name from Task.
I need a help here.. I am trying to extract Name from Tasks but I got the ID instead. Is there any way we could get the name from Task.
Map<Id,Contact> ContactMap = new Map<Id,Contact>([select id, Last_Activity_Subject__c, Last_Activity_Date__c, Last_Contact_First_Name__c, Last_Contact_Last_Name__c from Contact where id in:ContactIds]); for(Task t :Trigger.new) for(Contact l : ContactMap.Values()) { If(t.subject does not contain "words" ) // how to filter some subject from here? l.Last_Activity_Subject__c = t.subject; l.Last_Activity_Date__c = t.ActivityDate; l.Last_Contact_First_Name__c = t.WhoId; //<= I need a Name here Not an ID. ContactList.add(l); }Thanks in advance!
Greetings to you!
For if condition, you can use contains method. The contains method returns a boolean, so you can use boolean operators on the result.
If you want to get the name from a task you can use Who.Name
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
I tried that solution but it still saves it even though I put "2018" in the subject. After changing it to t.Who.Name, field became empty.