AquaLogic Interaction Development Kit (IDK) 6.0.0 |

# ITaskListManager.CopyTaskLists Method

Copies an array of task lists from a given source project to a target project.

void CopyTaskLists(
IProject sourceProject,
IProject targetProject,
ITaskList[] sourceTaskLists
);

#### Parameters

sourceProject
  The project that contains the specified source task lists; cannot be `null`.
targetProject
  The target project; cannot be `null`.
sourceTaskLists
  An `ITaskList` array to copy. Each of the task lists must be from the source project and the user must have permission to copy each task list. Cannot be `null`.

#### Remarks

If any name collisions occur, the name of the copied object will be modified to make it unique. All copied task lists will be persistent objects.

This method will do a best-attempt to copy the specified task lists. If an error occurs while copying one of the task lists, the copying will continue with appropriate exceptions thrown after the copy process finishes.

The status and risk field of each task in the source task list will be copied, but the assigned to field of each task will not be copied to avoid security discrepancy between the source project and target project.

Both the source project and the target project must be persisted prior to this copy operation. The following sample code shows how to copy task lists from a source project to a target project.

    //create the source project, and then persist it.
    IProject sourceProject = projectManager.CreateProject("Source Project Name", "Source Project Description");
    sourceProject.Store();
    //create the target project, and then persist it.
    IProject targetProject = projectManager.CreateProject("Target Project Name", "Target Project Description");
    targetProject.Store();

    //create a task list in the soucre project, and then persist it.
    ITaskList tasklist = tasklistManager.CreateTaskList(sourceProject, "Source Task List Name", "Source Task List Description");
    tasklist.Store();

    //create a task in the source task list, and then persist it.
    ITask task = tasklist.CreateTask("Task name", "Task description", new DateTime(2004, 9, 1), new DateTime(2004, 9, 8));
    task.Store();

    //copy the task lists from source project to target project
    //the copied task lists with containing tasks are already persisted by this method
    tasklistManager.CopyTaskLists(sourceProject, targetProject, new ITaskList { tasklist } );

#### Exceptions

Exception Type | Condition
--- | ---
CollaborationException | The method call resulted in an error, or the user does not have Read access to the given projects.
ArgumentException | The ID of the sourceProject is not > 0, or the ID of the targetProject is not > 0, or the ID of any of the task lists is not > 0.
MultipleObjectException | Errors occurred while copying. Each source exception can be retrieved from this exception. The exception should never happen unless source project content is being accessed concurrently with this copy operation.
SoapException | There was a communication problem during the execution of the remote method call.

#### See Also

ITaskListManager Interface | Plumtree.Remote.PRC.Collaboration.Tasklist Namespace