1

For a few days I'm trying to write the assignment progress for a specific task for a specific date. For example: I'm able to set the overall progress of the task but not the actual work that resource did at a given date. We are able to do that using Project Pro on the Task Usage view, but we need to automate some actions based on a file generated by another system and that's why i'm working in this solution but I could not find any object that would allow me to save the actual work value for a date. I'm using the CSOM library and Project Online.

EDIT:

Sorry if I was not clear for the first time... Basically, I need to get and set how many hours a resource worked in a single task for a single day. This can be done through the Task Usage view in the Project Pro (image below). I NEED to do this using CSOM and Project Server. I was able to get and set data for the resource and its assignments, but not by day, as I need.

Here is the image of the screen I'm talking about. Project Pro Task Usage View

This problem is driving me crazy! Any help would be very appreciated.

Thanks in advance!

1

At the end, we managed to find a way out... Here's how we did it:

    private void SaveAssignmentData(Guid id, DateTime start, DateTime finish, Config config)
    {  

        //start = DateTime.Today.AddHours(8);
        //finish = start.AddHours(10); //from 8am to 6pm

        var ctx = new Connection().ProjectOnline(config.SpOnlineSite, config.SpOnlineUsuario, config.SpOnlineSenha); //simple method to get the current context

        var resources = ctx.EnterpriseResources;
        ctx.Load(resources);
        ctx.ExecuteQuery();
        var resource = ctx.EnterpriseResources.FirstOrDefault(i => i.Email == "user@domain.com");
        if (resource == null) throw new Exception("Resource not found.");
        ctx.Load(resource, p => p.Assignments);
        ctx.ExecuteQuery();

        var timePhase = resource.Assignments.GetTimePhase(start, finish);
        ctx.Load(timePhase, p => p.Assignments);
        ctx.ExecuteQuery();

        var statusAssignment = timePhase.Assignments.FirstOrDefault(i => i.Id == id);
        if (statusAssignment != null)
        {
            statusAssignment.ActualWork = "6h";
            statusAssignment.SubmitStatusUpdates("through csom");
            ctx.ExecuteQuery();
        }
    }
1

The answer given by Andre Morata works very well, however, it only works if you are updating your own actuals (i.e. ProjectContext is logged in as MyUser while updating TimePhase for MyUser).

Currently it does not seem possible to establish a connection (ProjectContext) as one user to update timephased actuals for numerous resources.

This is something that plagues us today, does anyone perhaps have a solution?

  • to be able to accomplish that, we had to add the current user as the Assignment Owner for the users we were updating. But you are right when you say that this is something that plagues us... Regards – Andre Morata May 4 '17 at 19:37
  • Hey Andre, I did notice adding the Assignment Owner makes a difference. It allows us to read timephased actuals for resources other than the context user but it still does not allow us to update them. – Mark Corbin May 5 '17 at 14:39
  • by the way, you can check my post as well on this: sharepoint.stackexchange.com/questions/214501/… – Mark Corbin May 5 '17 at 19:22
1

Really weird but I have discovered that as the Assignment Owner I can read and update timephased actuals for other resources but it is really not intuitive to read this data.

Here is what I have discovered.

Let's say I have 2 resources, Bob and Sally. Bob is the assignment owner for Sally. I have two tasks, A100 and A200, Bob is assigned to A100 and Sally is assigned to A200.

//ctx user is Bob
var resource = ctx.EnterpriseResources.FirstOrDefault(i => i.Name == "Bob");
ctx.Load(resource, p => p.Assignments);
ctx.ExecuteQuery();

var timePhase = resource.Assignments.GetTimePhase(start, finish);
ctx.Load(timePhase, p => p.Assignments);
ctx.ExecuteQuery();
/*
This will give me a list of status assignments that also includes data for
Sally but it will look as though the status assignment is for Bob. If I update
one of the status assignments that belong to Sally sure enough I see the actuals
appear under Sally. This makes it difficult to read because I do not know which status assignments belong to which resource but I do get them all.
*/

var resource = ctx.EnterpriseResources.FirstOrDefault(i => i.Name == "Sally");
ctx.Load(resource, p => p.Assignments);
ctx.ExecuteQuery();

var timePhase = resource.Assignments.GetTimePhase(start, finish);
ctx.Load(timePhase, p => p.Assignments);
ctx.ExecuteQuery();
/*
My context user is Bob and I have loaded timephased actuals for Sally and I will
see only the status assignments for Sally but I am not able to update them.

I have to load the status assignments using Bob as the resource to update the status assignments for Sally.
*/

This is a really non-intuitive way to read and update status assignments. Thanks Microsoft lol

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.