I've create a function that pulls Id to a set, and a Map to contact that pulls id and in the SOQL statement compare the whoId from Task to Contact.ID then concatenate(Task.subject, Task.Type, Contact.Name) 3 fields to one custom field. I'm not sure how to proceed from here?

 public void ListOfTaskIds(list<Task> TaskEventList) {
        Set<ID> whoIdSet = new Set<ID>();
        for(Task e: TaskEventList){
            if(e.whoId != null){
        System.Debug('>>>>>>> the value of:' + whoIdSet);
        Map<ID, Contact> contactMap = new Map<ID, Contact>([select id, name from contact where id in :whoIdSet]);

  • not sure what you mean by word "slandered" in title. Possibly a typo?
    – Jagular
    Commented Mar 20, 2015 at 18:41
  • changed title obo OP
    – cropredy
    Commented Mar 20, 2015 at 19:32

2 Answers 2


I don't know what you mean by a "slandered" object. I'll assume you meant to say "Standard" object.

I don't know which sobject your custom field belongs to either. So I'll assume it's in the Task sobject (ie., Task.Your_Custom_Field__c).

I also don't understand your description of the code. But from reading it, I'll assume you're asking the community how to concatenate Task.Subject, Task.Type, and Contact.Name now that you've compiled your WhoId's and have a map of Contacts.

Here's the next block of code that I think you're looking for:

// Concatenate to Task.Your_Custom_Field__c
for (Task e : TaskEventList) {
    Contact c = contactMap.get(e.whoId);

    if (c != null) { 
        e.your_custom_field__c = e.subject + ' ' + e.type + ' ' + c.name;

Hope that helps!

  • 1
    Thanks! that works. and yes i meant "Standard" :)
    – Templar
    Commented Mar 20, 2015 at 20:54

You can do this for concatenating more than one Id.

String matrixId = '' + Account.Id + Contact.Id;


String matrixId = String.valueof(Account.Id) + String.valueof(Contact.Id) 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .