(Microsoft Project 2019 on-premise) DraftProjectResource does not update StandardRate

18 Views Asked by At

Our company uses Microsoft Project 2019 on-premise version. I try to write a C# code (CSOM) that updates project resource standard rate. I use the following code (it is an excerpt, full version can be found in example at UpdateProject.cs):

        projContext = GetContext(SiteUrl);

        csom.PublishedProject theProj = GetProjectById(projectId, projContext);

        Console.WriteLine("Got project " + theProj.Name);

        csom.DraftProject draft = theProj.CheckOut();

        projContext.Load(draft);
        projContext.Load(draft.ProjectResources, dp => dp.Where(r => r.Id == resourceId));
        projContext.ExecuteQuery();

        Console.WriteLine("Project " + draft.Name + " is checked out");

        csom.DraftProjectResource resource = draft.ProjectResources.First();

        Console.WriteLine("Got resource " + resource.Name + " with standard rate " + resource.StandardRate.ToString() + " per " + resource.StandardRateUnits.ToString());

        resource.StandardRate = 100.0d;
        //draft.Update();

        Console.WriteLine("New standard rate is " + resource.StandardRate.ToString());

        csom.JobState jobState = projContext.WaitForQueue(draft.Update(), DEFAULTTIMEOUTSECONDS);
        JobStateLog(jobState, "Updating project");

        jobState = projContext.WaitForQueue(draft.Publish(true), DEFAULTTIMEOUTSECONDS);
        JobStateLog(jobState, "Publishing project");

It shows expected messages (without errors) but when I look for standard rate in Project or re-run my program - it reads old value for standard rate. It seems like draft.Update() and draft.Publish(true) just do nothing for resource.

Can you please give me a hint where to look in order to correct this situation?

0

There are 0 best solutions below