none
Update 2013 Project Server Task Through PSI RRS feed

  • Question

  • I'm looking to implement a simple web app that lets me pass the UID, actual work and percent complete to it and update a task that has been assigned to a resource.  I've figured out how to get the assignments, but haven't been able to find the way to update the tasks in a supported manner.

    At this point - I just want a form handler that will take the values that have been passed and update the project - it could just take a simple web form POST and then I can go from there.

    Any suggestions on where I can find something to help me get started.  I've gone through the SDK, but I must not be smart enough to figure this part out...

    Any help would be much appreciated!


    Wednesday, November 5, 2014 6:22 AM

Answers

  • I suggest you to use the Project Server client object model instead of PSI. It is much easier to use and one can write more readable code.

    In this case you can change the actual work and percent complete properties of your task via a code like the one below:

    var pwaUrl = @"http://YourServer/pwa";
    var projectContext = new ProjectContext(pwaUrl);
    
    // if you know the project name, you can use this code
    projectContext.Load(projectContext.Projects, ps => ps.Include(p => p.Name, p => p.Tasks.Include(t => t.Id, t => t.Name)));
    projectContext.ExecuteQuery();
    
    var proj = projectContext.Projects.First(p => p.Name == "Your Project Name");
    
    // alternatively, you can use the project ID, if it is known
    //var projId = new Guid("98138ffd-d0fa-e311-83c6-005056b45654");
    //var proj = projectContext.Projects.GetByGuid(projId);
    
    // if you know the task name, you can use this code
    var taskId = proj.Tasks.First(t => t.Name == "Your Task").Id;
    
    // alternatively, you can use the task ID, if it is known
    //var var taskId = new Guid("b0a7e41d-4ed4-e311-83c6-005056b45654");
    
    var draftProj = proj.CheckOut();
    
    var task = draftProj.Tasks.GetByGuid(taskId);
    task.ActualWork = "20d";
    task.PercentComplete = 50;
    draftProj.Publish(true);
    
    // If project already checked out, an excpetion will be thwrown:
    // An unhandled exception of type 'Microsoft.SharePoint.Client.ServerException' occurred in Microsoft.SharePoint.Client.Runtime.dll
    // Additional information: CSOMUnknownUser
    projectContext.ExecuteQuery();

    Wednesday, November 5, 2014 1:59 PM

All replies

  • Hi MatthewKSwanson,

    Before looking into coding, have you tried using the My Task functionality where the information you want to update already exists? If your resources do not have access to project server then you can change the assignment owner to someone that has access to project server and can provide the updates (e.g. team leader)

    Or maybe you have the updates provided by another system?

    Paul

    Wednesday, November 5, 2014 11:26 AM
  • We have considered it, but have a specific use case that will require programmatic interaction with the tasks.
    Wednesday, November 5, 2014 1:02 PM
  • I suggest you to use the Project Server client object model instead of PSI. It is much easier to use and one can write more readable code.

    In this case you can change the actual work and percent complete properties of your task via a code like the one below:

    var pwaUrl = @"http://YourServer/pwa";
    var projectContext = new ProjectContext(pwaUrl);
    
    // if you know the project name, you can use this code
    projectContext.Load(projectContext.Projects, ps => ps.Include(p => p.Name, p => p.Tasks.Include(t => t.Id, t => t.Name)));
    projectContext.ExecuteQuery();
    
    var proj = projectContext.Projects.First(p => p.Name == "Your Project Name");
    
    // alternatively, you can use the project ID, if it is known
    //var projId = new Guid("98138ffd-d0fa-e311-83c6-005056b45654");
    //var proj = projectContext.Projects.GetByGuid(projId);
    
    // if you know the task name, you can use this code
    var taskId = proj.Tasks.First(t => t.Name == "Your Task").Id;
    
    // alternatively, you can use the task ID, if it is known
    //var var taskId = new Guid("b0a7e41d-4ed4-e311-83c6-005056b45654");
    
    var draftProj = proj.CheckOut();
    
    var task = draftProj.Tasks.GetByGuid(taskId);
    task.ActualWork = "20d";
    task.PercentComplete = 50;
    draftProj.Publish(true);
    
    // If project already checked out, an excpetion will be thwrown:
    // An unhandled exception of type 'Microsoft.SharePoint.Client.ServerException' occurred in Microsoft.SharePoint.Client.Runtime.dll
    // Additional information: CSOMUnknownUser
    projectContext.ExecuteQuery();

    Wednesday, November 5, 2014 1:59 PM
  • Hi,

    An example for Statusing.UpdateStatus method can be found here:

    http://msdn.microsoft.com/en-us/library/office/gg209876(v=office.15).aspx

    Hope this helps

    Paul

    Wednesday, November 5, 2014 2:14 PM