EnterpriseResource class

Represents a resource that is managed by Project Server in a project.

Inheritance hierarchy


Namespace:  Microsoft.ProjectServer.Client
Assembly:  Microsoft.ProjectServer.Client (in Microsoft.ProjectServer.Client.dll)


<ScriptTypeAttribute("PS.EnterpriseResource", ServerTypeId := "{f6167b82-e04e-4ce2-8631-09ce14f6277e}")> _
Public Class EnterpriseResource _
    Inherits ClientObject
Dim instance As EnterpriseResource
[ScriptTypeAttribute("PS.EnterpriseResource", ServerTypeId = "{f6167b82-e04e-4ce2-8631-09ce14f6277e}")]
public class EnterpriseResource : ClientObject


You can get an EnterpriseResource object for editing by using the GetByGuid, GetById, or GetByUser method on the EnterpriseResourceCollection object. When you make a change to one of the editable properties, and then save the change, Project Server automatically checks out the resource, makes the change, and then checks the resource back in. This is similar to the process of opening an enterprise resource in Project Professional 2013, editing it, and then saving and closing the enterprise resource.


The following example uses the EnterpriseResourceCollection.GetByGuid method to get an EnterpriseResource object for editing. The example toggles the CanLevel property from True to False.

If the resource is already checked out, the example throws a PJClientCallableException, such as CICOAlreadyCheckedOutToYou. You can use Try –Catch statements to handle the exception, or use the IsCheckedOut property to determine whether an edit can be done.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ProjectServer.Client;

namespace EditEntResource
    class Program
        private const string pwaPath = "http://ServerName/pwa/";    // Change the path for your Project Web App.
        // Set the Project Server client context.
        private static ProjectContext projContext;

        static void Main(string[] args)
            projContext = new ProjectContext(pwaPath); 

            Guid entResUid = new Guid("9f164f32-d985-e211-93f8-0021704e28a0");

            // Get the list of enterprise resources in Project Web App.

            int numResInCollection = projContext.EnterpriseResources.Count();

            if (numResInCollection > 0)

                var entRes2Edit = projContext.EnterpriseResources.GetByGuid(entResUid);

                Console.WriteLine("\nEditing resource : GUID : Can Level");
                Console.WriteLine("\n{0} : {1} : {2}", entRes2Edit.Name, entRes2Edit.Id.ToString(),

                // Toggle the CanLevel property.
                entRes2Edit.CanLevel = !entRes2Edit.CanLevel;

                // The entRes2Edit object is in the EnterpriseResources collection.
                // Save the change.

                // Check that the change was made.

                entRes2Edit = projContext.EnterpriseResources.GetByGuid(entResUid);

                Console.WriteLine("\n\nChanged resource : GUID : Can Level");
                Console.WriteLine("\n{0} : {1} : {2}", entRes2Edit.Name, entRes2Edit.Id.ToString(),

            Console.Write("\nPress any key to exit: ");

Following is sample output:

Editing resource : GUID : Can Level
TestUser Name : 9f164f32-d985-e211-93f8-0021704e28a0 : True

Changed resource : GUID : Can Level
TestUser Name : 9f164f32-d985-e211-93f8-0021704e28a0 : False
Press any key to exit:

Thread safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See also


EnterpriseResource members

Microsoft.ProjectServer.Client namespace