project online CSOM : Need to publish 2 times for changes to appear in the web app

Copper Contributor

While using the CSOM for project online, I encountered a weird bug.

I'm updating a resource timephased data as the project manager, everything seems to work fine but when I publish and check in,
the changes are not visible in the web App. I can see the successful requests in the webApp activity log, and the changes are even
visible when iI stop the app, then fetch my timePhase again from the projectsContext.

The only workaround that I found is to publish and checkIn 2 times in a row, then the data is visible in the webApp.

Anybody knows what is going on?

Thank you

Sample code :

 

 

 //Testing purposes
                if (checkedOut == false) {
                    TimePhase timePhase = r.Assignments.GetTimePhase(DateTime.Now.AddDays(1), DateTime.Now.AddDays(1));
                    projContext.Load(timePhase.Assignments, a => a.IncludeWithDefaultProperties(x => x.Project));
                    projContext.ExecuteQuery();

                    StatusAssignment statusAssignment = timePhase.Assignments.FirstOrDefault(x => x.Project.Name == "Test TI");
                    if (statusAssignment != null) {
                        statusAssignment.ActualWork = "5h";
                        statusAssignment.SubmitStatusUpdates("through csom");
                    }


                    DraftProject draft = p.CheckOut();
                    draft.Update();
                    projContext.Load(draft.Tasks, ts =>
                    ts.Include(
                    t => t.Id,
                    t => t.Name,
                    t => t.CustomFields,
                    t => t.OutlineLevel,
                    t => t.IsSummary));

                    //here, need to publish 2 times to be visible in webapp
                    for (int i = 0; i < 2; i++) {
                    draft.Publish(true);
                    projContext.ExecuteQuery();

                    draft.CheckIn(true);
                    projContext.ExecuteQuery();
                    }
                }
                else {
                    return false;
                }

 

 

0 Replies