Develop project templates with Copy Project

Completed

If your organization has projects with similar attributes and work breakdown structure, then you can accelerate the project creation process with the use of project templates.

You can set up one or more project templates with common project properties and other information, such as team members, project tasks, estimates, and so on. For more information, see Project templates.

When a project template has been set up in Project Operations, you can create a new project by copying it from the project template. The following entities will be copied from the project template:

  • Project

  • Project checklists

  • Project buckets

  • Project team members

  • Project task

  • Project task dependency

  • Resource assignment

  • Project estimates (including labor, expense, and material estimates)

You can use the project template in conjunction with the Copy Project API. You might consider using this feature during data migration to migrate projects and copy data from a template project, as previously discussed.

Code example

The following example shows how to call the CopyProjectV3 custom action with the removeNamedResources parameter set.

using System;
using Microsoft.Xrm.Sdk;

public class CopyProjectSample
{
    private IOrganizationService organizationService;

    public CopyProjectSample(IOrganizationService organizationService)
    {
        this.organizationService = organizationService;
    }

    public void SampleRun()
    {
        // Example source project GUID
        Guid sourceProjectId = new Guid("11111111-1111-1111-1111-111111111111");
        var sourceProject = new Entity("msdyn_project", sourceProjectId);

        Entity targetProject = new Entity("msdyn_project");
        targetProject["msdyn_subject"] = "Example Project - Copy";
        targetProject.Id = organizationService.Create(targetProject);

        CallCopyProjectAPI(sourceProject.ToEntityReference(),
            targetProject.ToEntityReference(),
            true,
            false);
        Console.WriteLine("Done ...");
    }

    private void CallCopyProjectAPI(
        EntityReference sourceProject,
        EntityReference TargetProject,
        bool replaceNamedResources = true,
        bool clearTeamsAndAssignments = false)
    {
        OrganizationRequest req = new OrganizationRequest("msdyn_CopyProjectV3");
        req["SourceProject"] = sourceProject;
        req["Target"] = TargetProject;

        if (replaceNamedResources)
        {
            req["ReplaceNamedResources"] = true;
        }
        else
        {
            req["ClearTeamsAndAssignments"] = true;
        }

        OrganizationResponse response = organizationService.Execute(req);
    }
}

For more information, see Develop project templates with Copy Project.