I am getting all the contact Ids in SetOfId and I want to relate one task to multiple contact.
public Task_Controller() {
if (ApexPages.currentPage().getParameters().get('SetOfId') != null) {
for (String s: ApexPages.currentPage().getParameters().get('SetOfId').split(',')) {
SetOfId.add(s);
System.debug('SetOfId is####' + SetOfId);
}
}
create_task();
}
public void create_task() {
// Instanciate Object
tskNew = new Task();
// Pre-populate Fields
tskNew.WhoId =
tskNew.WhatId =
tskNew.Subject =
tskNew.OwnerId = userInfo.getUserId();
}
public pagereference save() {
insert tsk;
return stdController.save();
}
Something similar to this:
List < id > listOfCon = new List < id > ();
for (Contact c: [select id from Contact where Id in: SetOfId]) {
listOfCon.add(c.id);
System.debug('listOfCon is####' + listOfCon);
}
then
for (Contact c : listOfCon){
tsk = new Task();
}