Forum Discussion

Ihor_Kozlitin's avatar
Ihor_Kozlitin
Copper Contributor
Feb 16, 2024

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

Hello!

 

Our company uses Microsoft Project 2019 on-premise version. I try to write a C# code that updates  project resource standard rate. I use the followin code (it is excerpt, full version can be found 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.Publish(true), DEFAULTTIMEOUTSECONDS);
            JobStateLog(jobState, "Updating 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?

No RepliesBe the first to reply

Resources