MS Project Server 2016: create new assignemnt by user using Client Side Object Model (CSOM)

587 views Asked by At

Our users (resources) can assign themselves to existing tasks via a custom frontend.

In Project Server 2010 we used the PSI that is no longer supported in the current version.

StatusingClient sc = new StatusingClient(httpBinding, endpointAddress);
sc.CreateNewAssignmentWithWork(parameters);

This assignment-request could then be approved by a projectleader with planning permissions.

We could not find an equivalent method within the CSOM.

Using the CSOM we can only create new assignments as a user with planning permissions (but of course not all users should have those rights).

        DraftProject projectDraft = pubProject.CheckOut();
        projContext.Load(projectDraft.Tasks);
        projContext.ExecuteQuery();

        var task = projectDraft.Tasks.Where(t => t.Id == taskUid).FirstOrDefault();

        if (task != null)
        {
            AssignmentCreationInformation assignment = new AssignmentCreationInformation();

            assignment.Id = Guid.NewGuid();
            assignment.TaskId = task.Id;
            assignment.ResourceId = userRes.Id;
            task.Assignments.Add(assignment);
            projectDraft.Assignments.Add(assignment);
            projectDraft.Update();
        }

        projContext.ExecuteQuery();

        projectDraft.Publish(true);
        projectDraft.CheckIn(true);

        projContext.ExecuteQuery();

Any hints how to solve this task?

1

There are 1 answers

0
DaFloDo On

Contrary to the official documentation, the statusing functionality of the deprecated PSI is still working in 2016. So for us the solution is using the PSI and its StatusingClient as before in 2010 and 2013.

Going the CSOM way, the user who creates a new assignment, has to have edit privileges for the project, since the project has to be checked out and modified.