none
Best way to update existing assignment? RRS feed

  • Question

  • Platform is MSP 2007, connecting to Project Server.

    What is the best way to find and update an existing assignment?

    Currently, I run a loop and try to match an assignment based on matching:

      1) An enterprise field

      2) Worked Date

      3) Resource Guid

    I am running the loop on all existing assignments to match my incoming data using above fields. It seems horribly inefficient. 

    Thanks,

    Marc

    Wednesday, September 19, 2012 10:45 PM

Answers

  • that is the way to do it. For sure it take some time so you will want to make your checks as efficient as possible and you may, depending on your needs, also make sure that you kick outof the loop if you find what you need. for example if you know it is only going to return one task and you find it then kick out of hte loop so you dont keep looping after you have found it.

    Brian Kennemer - Project MVP
    DeltaBahn Senior Architect
    endlessly obsessing about Project Server…so that you don’t have to.
    Blog | Twitter | LinkedIn

    • Marked as answer by MarcKriez Thursday, September 20, 2012 4:23 PM
    Thursday, September 20, 2012 4:38 AM
    Moderator

All replies

  • Marc,

    In order for someone to be able to help you, more information is needed. For example, you mention running a loop. Are you using VBA, PSI or something else? And what do you mean by "update an existing assignment"? What is your end goal?

    John

    Thursday, September 20, 2012 2:27 AM
  • John, thanks for the response.

    I want to find an assignment matching the fields mentioned. So I wrote a loop (in C#) to iterate through 

    Application.ActiveProject.Tasks and Tasks.Assignments.

    In partial pseudocode:

    foreach (Task singleTask in ActiveProject.Tasks) { // check for matches on the enterprise field foreach (Assignment singleAsmt in singleTask.Assignments) { // check for matches on Worked Date and ResourceGuid

    // break out of the loop when all 3 criteria matched

    } }

    You can see how this can be time consuming if the project is large. 

    It's written in C# using VSTO in Visual Studio 2010. 

    GOAL: When (if) the assignment is found, some of the assignment's properties are changed.

    It feels like it's the wrong way to do it, so I'm looking for a better way.

    Thanks!

    Marc


    Thursday, September 20, 2012 2:41 AM
  • that is the way to do it. For sure it take some time so you will want to make your checks as efficient as possible and you may, depending on your needs, also make sure that you kick outof the loop if you find what you need. for example if you know it is only going to return one task and you find it then kick out of hte loop so you dont keep looping after you have found it.

    Brian Kennemer - Project MVP
    DeltaBahn Senior Architect
    endlessly obsessing about Project Server…so that you don’t have to.
    Blog | Twitter | LinkedIn

    • Marked as answer by MarcKriez Thursday, September 20, 2012 4:23 PM
    Thursday, September 20, 2012 4:38 AM
    Moderator
  • Thanks for your response. 

    I accept your answer. And yes, I do a short-circuit break out of the loop once the assignment is found. 

    Peace.

    Thursday, September 20, 2012 4:23 PM