none
Add resource assignment work by day RRS feed

  • Question

  • 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.

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

    Friday, June 24, 2016 8:09 PM

Answers

  • 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();
                }
            }

    • Marked as answer by Andre L Morata Wednesday, July 20, 2016 11:54 AM
    Wednesday, July 20, 2016 11:54 AM

All replies

  • If its only needed for a specific task, open the project in Project Pro and either copy/paste to Excel or use VBA See (https://msdn.microsoft.com/en-us/subscriptions/downloads/ee355231.aspx ) - much faster to code.

    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Sunday, June 26, 2016 5:15 AM
    Moderator
  • Hi Andre,

    Are you looking for remote updatation of task.

    Here is example,

    https://amjadk.com/2016/06/20/o365-tool-to-upload-your-files-remotely-powershell-and-csom-sharepoint-online/

    please let me know if you need more details.

    Please Marked as Answer , if useful.


    Amjad Khan

    Sunday, June 26, 2016 5:46 AM
  • Thanks for the reply.

    This is not what I'm looking for. I need to do it through code, via CSOM on Project Online. That is necessary because I need to change/set the actual work by day for all assignments of the resource, in all project he is included.

    Tuesday, June 28, 2016 9:30 PM
  • Hi. Thanks for the reply.

    I don't see how this script could help me... I it the correct one?

    Tuesday, June 28, 2016 9:31 PM
  • 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();
                }
            }

    • Marked as answer by Andre L Morata Wednesday, July 20, 2016 11:54 AM
    Wednesday, July 20, 2016 11:54 AM