none
project server 2016: CSOM timephased data RRS feed

  • Question

  • Hello,

    We have a requirement in which we need to update the actual work per day of an EPM project through the CSOM. For that, we have found the below working code:

     private void SaveAssignmentData(ProjectContext ctx, Guid id, DateTime start, DateTime finish, Config config)
        {  
            var resources = ctx.EnterpriseResources;
            ctx.Load(resources);
            ctx.ExecuteQuery();
            var resource = ctx.EnterpriseResources.FirstOrDefault(i => i.Name == "Generic Resource1");
            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();
            }
        }

    However, this code only works for non-generic resources. For generic resources, the resource.Assignments always returns null. EPM seems to automatically create a StatusAssignment for non-generic resources that this code uses to add actual work per day but EPM doesn't automatically create a StatusAssignment for generic resources. We have tried creating a StatusAssignment for the generic resource but failed because we can't find a way to link the StatusAssignment to the specific task.

    Any help is much appreciated. Thank you!


    • Edited by geo_d Wednesday, March 8, 2017 10:36 AM
    Monday, March 6, 2017 5:02 PM

All replies

  • Hi,

    this is the expected behavior. There is no status update possible for generic resources, even not without code. In the past, you could assign an assignment owner to a assignment for generic resources. When doing so, the assignment owner could enter status updates on his own tasks page. Now, you can't do so and therefore you can't enter any status updates for a generic resource. In my opinion, it makes sense, that you are also not able to do so using CSOM.

    As a solution, you could think about using non-generic resources without login and without setting them to generic, and use them instead of your current generic resources?

    By the way: the idea behind generic resources is to use them mainly for planning purposes. So from design perspective, there should not be any progress performed by a generic resource.

    Regards
    Barbara


    To increase the value of this forum, please mark the replies that helped to solve your issue as answer. If you find answers to questions from other forum participants to be helpful, please mark them as helpful. Your participation will help others to find an appropriate solution faster. Thanks for your support!

    Wednesday, March 8, 2017 11:26 AM
    Moderator
  • Hello Barbara,

    Thank you for your prompt answer.

    In our environment, project teams change very often and frequently so we would rather track progress on generic resources instead of real resources.

    What I need to do is register actual work hours per day for the generic resources programatically. This is possible through Microsoft Project's windows application as shown in the attached image (highlighted in yellow). I thought that this can be achieved programmatically through the code I have posted before. It turned out that it is possible for real resources but not for generic ones. Is there any other code, other than the StatusAsssignment and GetTimePhase, that allows us to update the the actual work/actual overtime hours per day for generic resources?

    

    Thanks again for your help. Much appreciated.




    • Edited by geo_d Wednesday, March 8, 2017 12:38 PM
    Wednesday, March 8, 2017 12:36 PM
  • Hi,

    I see what you want to achieve. How this could be done for generic resource, some-one else has to respond.

    But since Statusing just does not work for generic resources: Why don't you want to use resources not being users? Just set them up like your generic resource, just without flag "generic". I am doing this quite often and call them semi-generic: I am using them in the same way as generic resource, and avoid some restrictions linked to "generic".

    Regards
    Barbara


    To increase the value of this forum, please mark the replies that helped to solve your issue as answer. If you find answers to questions from other forum participants to be helpful, please mark them as helpful. Your participation will help others to find an appropriate solution faster. Thanks for your support!

    Thursday, March 9, 2017 8:43 AM
    Moderator
  • Thanks again Barbara. I will try to find a solution using generic resources. If it doesn't work, I will use your method of semi-generic resources.

    Regards,
    George

    Thursday, March 9, 2017 8:51 AM