Skip to main content
deleted 2 characters in body
Source Link
Shailesh Patil
  • 1.9k
  • 13
  • 19

Here, you have to use the Split function on the string which will break the string in the set of words using the deliminator and return you a list. Try this code:

    trigger MultiTaskCreate on Task (before insert) {

Map<task, List<Id>> taskToUsersIds = new Map<task, List<Id>>();
for(Task ts: trigger.new){
    if(taskts.UserListField__c != null){
            taskToUsersIds.put(ts, ts.UserListField__c.split(','));
        }
}
List<task> taskToInsert = new List<task>();
for(Task t : taskToUsersIds.keySet())
{
    for(String userId : taskToUsersIds.get(t))
    {
            Task task = new Task();
            task.Assigned_To__c = userId; //You will get the UserId here
            task.Status = 'Completed';
            task.Priority = ts.Priority;
            task.Communication_Type__c = ts.Communication_Type__c;
            task.Subject = ts.Subject;
            task.Name__c = ts.Name__c;
            taskToInsert.add(task);

    }

}
 if(taskToInsert.size() > 0)
    insert taskToInsert;
}

Here, you have to use the Split function on the string which will break the string in the set of words using the deliminator and return you a list. Try this code:

    trigger MultiTaskCreate on Task (before insert) {

Map<task, List<Id>> taskToUsersIds = new Map<task, List<Id>>();
for(Task ts: trigger.new){
    if(task.UserListField__c != null){
            taskToUsersIds.put(ts, ts.UserListField__c.split(','));
        }
}
List<task> taskToInsert = new List<task>();
for(Task t : taskToUsersIds.keySet())
{
    for(String userId : taskToUsersIds.get(t))
    {
            Task task = new Task();
            task.Assigned_To__c = userId; //You will get the UserId here
            task.Status = 'Completed';
            task.Priority = ts.Priority;
            task.Communication_Type__c = ts.Communication_Type__c;
            task.Subject = ts.Subject;
            task.Name__c = ts.Name__c;
            taskToInsert.add(task);

    }

}
 if(taskToInsert.size() > 0)
    insert taskToInsert;
}

Here, you have to use the Split function on the string which will break the string in the set of words using the deliminator and return you a list. Try this code:

    trigger MultiTaskCreate on Task (before insert) {

Map<task, List<Id>> taskToUsersIds = new Map<task, List<Id>>();
for(Task ts: trigger.new){
    if(ts.UserListField__c != null){
            taskToUsersIds.put(ts, ts.UserListField__c.split(','));
        }
}
List<task> taskToInsert = new List<task>();
for(Task t : taskToUsersIds.keySet())
{
    for(String userId : taskToUsersIds.get(t))
    {
            Task task = new Task();
            task.Assigned_To__c = userId; //You will get the UserId here
            task.Status = 'Completed';
            task.Priority = ts.Priority;
            task.Communication_Type__c = ts.Communication_Type__c;
            task.Subject = ts.Subject;
            task.Name__c = ts.Name__c;
            taskToInsert.add(task);

    }

}
 if(taskToInsert.size() > 0)
    insert taskToInsert;
}
Code changes
Source Link
Shailesh Patil
  • 1.9k
  • 13
  • 19

Here, you have to use the Split function on the string which will break the string in the set of words using the deliminator and return you a list. Try this code:

    trigger MultiTaskCreate on Task (before insert) {
 
//Trying to Make the List of Users Id's instead of string
List<String> UsrId = new List<String>();
Map<IdMap<task, List<Id>> taskToUsersIds = new Map<IdMap<task, List<Id>>();
List<task> taskToInsert = new List<task>();
for(Task ts: trigger.new){
    if(task.UserListField__c != null){
        for(String userId : task taskToUsersIds.put(ts, ts.UserListField__c.split(','));
        }
}
List<task> taskToInsert = new List<task>();
for(Task t : taskToUsersIds.keySet())
{
    for(String userId : taskToUsersIds.get(t))
    {
            Task task = new Task();
            task.Assigned_To__c = userId; //You will get the UserId here
            task.Status = 'Completed';
            task.Priority = ts.Priority;
            task.Communication_Type__c = ts.Communication_Type__c;
            task.Subject = ts.Subject;
            task.Name__c = ts.Name__c;
            taskToInsert.add(task);

        }
    }
}
 if(taskToInsert.size() > 0)
    insert taskToInsert;
}

Here, you have to use the Split function on the string which will break the string in the set of words using the deliminator and return you a list. Try this code:

trigger MultiTaskCreate on Task (before insert) {
 
//Trying to Make the List of Users Id's instead of string
List<String> UsrId = new List<String>();
Map<Id, List<Id>> taskToUsersIds = new Map<Id, List<Id>>();
List<task> taskToInsert = new List<task>();
for(Task ts: trigger.new){
    if(task.UserListField__c != null){
        for(String userId : task.UserListField__c.split(','))
        {
            Task task = new Task();
            task.Assigned_To__c = userId; //You will get the UserId here
            task.Status = 'Completed';
            task.Priority = ts.Priority;
            task.Communication_Type__c = ts.Communication_Type__c;
            task.Subject = ts.Subject;
            task.Name__c = ts.Name__c;
            taskToInsert.add(task);

        }
    }
}
 if(taskToInsert.size() > 0)
    insert taskToInsert;
}

Here, you have to use the Split function on the string which will break the string in the set of words using the deliminator and return you a list. Try this code:

    trigger MultiTaskCreate on Task (before insert) {

Map<task, List<Id>> taskToUsersIds = new Map<task, List<Id>>();
for(Task ts: trigger.new){
    if(task.UserListField__c != null){
            taskToUsersIds.put(ts, ts.UserListField__c.split(','));
        }
}
List<task> taskToInsert = new List<task>();
for(Task t : taskToUsersIds.keySet())
{
    for(String userId : taskToUsersIds.get(t))
    {
            Task task = new Task();
            task.Assigned_To__c = userId; //You will get the UserId here
            task.Status = 'Completed';
            task.Priority = ts.Priority;
            task.Communication_Type__c = ts.Communication_Type__c;
            task.Subject = ts.Subject;
            task.Name__c = ts.Name__c;
            taskToInsert.add(task);

    }

}
 if(taskToInsert.size() > 0)
    insert taskToInsert;
}
Source Link
Shailesh Patil
  • 1.9k
  • 13
  • 19

Here, you have to use the Split function on the string which will break the string in the set of words using the deliminator and return you a list. Try this code:

trigger MultiTaskCreate on Task (before insert) {

//Trying to Make the List of Users Id's instead of string
List<String> UsrId = new List<String>();
Map<Id, List<Id>> taskToUsersIds = new Map<Id, List<Id>>();
List<task> taskToInsert = new List<task>();
for(Task ts: trigger.new){
    if(task.UserListField__c != null){
        for(String userId : task.UserListField__c.split(','))
        {
            Task task = new Task();
            task.Assigned_To__c = userId; //You will get the UserId here
            task.Status = 'Completed';
            task.Priority = ts.Priority;
            task.Communication_Type__c = ts.Communication_Type__c;
            task.Subject = ts.Subject;
            task.Name__c = ts.Name__c;
            taskToInsert.add(task);

        }
    }
}
 if(taskToInsert.size() > 0)
    insert taskToInsert;
}