none
Updating Project Start Date via C# / PSI RRS feed

  • Question

  • Does anyone have a working example of updating the project start date using C# and the project server web services?

    I'm using the CreateProjectFromTemplate command. I've tried updating the existing dataset:

    var dataSet = clientService.ProjectClient.ReadProject(projectId, DataStoreEnum.WorkingStore);
    dataSet.Project[0].PROJ_INFO_START_DATE = projectModel.StartDate;

    and adding a new dataset 

    var dataSet = new ProjectDataSet();
     var newRow = dataSet.Project.NewProjectRow();
     newRow.PROJ_INFO_START_DATE = projectModel.StartDate;

    But the project still retains the Project Start Date from the template.

    Monday, November 16, 2015 6:31 PM

Answers

  • I found I needed to create the project from the template. Then perform a checkout and save the dates. I also had a call to AcceptChanges() which was causing the dates not to save. Once I removed this I was able to set the project start and end dates.

    var dataSet = clientService.ProjectClient.ReadProject(projectId, DataStoreEnum.WorkingStore);
    var projectRow = dataSet.Project[0];
    projectRow.PROJ_INFO_START_DATE = projectModel.StartDate;
    projectRow.PROJ_INFO_FINISH_DATE = projectModel.EndDate;
    var jobId = Guid.NewGuid();
    clientService.ProjectClient.QueueUpdateProject(jobId, sessionId, dataSet, false);

    • Marked as answer by Marc DeAntoni Tuesday, November 17, 2015 3:30 PM
    Tuesday, November 17, 2015 3:30 PM

All replies

  • You can not forcefully put the start date through code. Start date of the project comes from the earliest start date of the tasks under the project. In case there are not tasks in the schedule only then this would work that to while creating the project.

    Regards, Syed Faizan ur Rehman, CBPM®,PRINCE2®, MCTS

    Tuesday, November 17, 2015 7:51 AM
  • I've found quite often in the past that I needed to set this in two times:

    1) Create the Project using the Template

    2) Read the Project Again, set additional fields like Project Start Date, Save and Publish

    The reason being is that information that comes from the template sometimes take precedence over the information your setting, a little bit bizarre.


    If you think this was valuable please mark my reply as a valid answer. Thanks. Kind Regards, João Frederico Neto --

    Tuesday, November 17, 2015 9:26 AM
  • To be accurate Project Start Date != min Start date of the Plan.

    Project Start Date is an independent field that is stored on the column PROJ_INFO_START_DATE, while the minimum date is stored in the task with ID 0, on the column TASK_START_DATE.

    TASK_START_DATE will contain the minimum date of the plan, PROJ_INFO_START_DATE must contain a date lower or equal than this.


    If you think this was valuable please mark my reply as a valid answer. Thanks. Kind Regards, João Frederico Neto --

    Tuesday, November 17, 2015 9:29 AM
  • I found I needed to create the project from the template. Then perform a checkout and save the dates. I also had a call to AcceptChanges() which was causing the dates not to save. Once I removed this I was able to set the project start and end dates.

    var dataSet = clientService.ProjectClient.ReadProject(projectId, DataStoreEnum.WorkingStore);
    var projectRow = dataSet.Project[0];
    projectRow.PROJ_INFO_START_DATE = projectModel.StartDate;
    projectRow.PROJ_INFO_FINISH_DATE = projectModel.EndDate;
    var jobId = Guid.NewGuid();
    clientService.ProjectClient.QueueUpdateProject(jobId, sessionId, dataSet, false);

    • Marked as answer by Marc DeAntoni Tuesday, November 17, 2015 3:30 PM
    Tuesday, November 17, 2015 3:30 PM
  • Yes, that was what I was referring to, great stuff!

    If you think this was valuable please mark my reply as a valid answer. Thanks. Kind Regards, João Frederico Neto --

    Tuesday, November 17, 2015 3:47 PM