3

We have always updated timephased data in Microsoft Project using PSI (impersonation) and are trying to mimic this solution with CSOM to allow integration with Project Online. Much to our dismay we have yet to find a solution due to security restrictions with timephased data.

We can read TimePhase quite well:

//create context...
var context = new ProjectContext(ProjectSite);

//login...
var securePassword = new SecureString();
foreach (char c in user.Password)
securePassword.AppendChar(c);
context.Credentials = new SharePointOnlineCredentials(userName, securePassword);

//load web...
context.Load(context.Web);

//load enterprise resources...
context.Load(context.EnterpriseResources);
context.ExecuteQuery();

//read timephase for enterprise resource...
var timePhase = context.EnterpriseResources[0].Assignments.GetTimePhase(start, end);
context.Load(timePhase.Assignments);
context.ExecuteQuery();

/*
NOTE: this will fail (GeneralSecurityAccessDenied) if the enterprise resource is not associated to the context user, however, if the context user is the assignment owner we seem to be able to read the TimePhase regardless of who the enterprise resource is.
*/

//update and submit actual work on timePhase...
timePhase.Assignments[0].ActualWork = "12h";
timePhase.Assignments[0].SubmitStatusUpdates("CSOM Update");
SessionManager.ProjectOnlineContext.ExecuteQuery();

/*
NOTE: this will fail (GeneralSecurityAccessDenied) if the enterprise resource is not associated to the context user and we have not found a way around this.
*/

We have the following issues:

  • TimePhase data can only be read for the Context User or for assignments where the Context User is the Assignment Owner
  • TimePhase data cannot be updated for resources other than the Context User.

Our solution requires connecting to Project Online as one user to update timephased data for all resources in any given project. The security restrictions prevent us from performing this kind of integration.

Anyone have any thoughts, solutions, or workarounds?

3
  • Are you saying that you have to have the credentials of the user that owns the assignment or the project owner? I’m building an entire process for project creation and assignment updates but I’m running into a threshold issue 1000 resource limit on loading the status assignment collection. If only the person that owns the assignment can do the update I’m hoping you mean the project owner not the actual a assignment resource. Can we connect off this thread to talk Thanks Don
    – Don
    Commented Oct 21, 2017 at 18:11
  • Hi Don, updating assignments (DraftAssignment) and updating TimePhase/StatusAssignment are two different things. The context you need depends on what you want to update. For example, if you just want to update Actual Work for an assignment you don't need to update Status Assignment unless you want to update Time Phase and the context for updating one or the other can be different. If you want to share code samples offline to better target what it is you are looking to accomplish and the context you need please feel free to PM/e-mail me. Commented Oct 22, 2017 at 9:28
  • My e-mail is [email protected] Commented Oct 22, 2017 at 13:00

3 Answers 3

2

Unfortunately there is not a way to bulk submit status updates on the behalf of other users. An app can only update the status of the task as the user who is authenticated with Project Online.

Chris Boyd

Principal PM Manager, Microsoft Project Team

2
  • Hi Chris, thanks for your comment. We have found success with this if we set the assignment owner (and potentially status manager) to a single user/resource; we then use that user/resource to obtain a ProjectContext and basically bypass all the security issues. Obviously, there might be concern to having all assignment owners (and potentially status managers) configure to be a single user/resource; what are your thoughts on this approach? Commented May 12, 2017 at 23:42
  • Also, I have been at Microsoft Build 2017 this week and talking to people from the SharePoint team they have turned us on to creating a provider-hosted add-in with app only permissions which should allow us to do as we please, do you have any experience with this approach? Commented May 12, 2017 at 23:47
0

I have actually discovered how to accomplish this task although it is really not intuitive and more difficult than it needs to be.

I have been discussing this in another post:

Add resource assignment work by day

Basically, to update timephased data (status assignments) for other resources the context user must be the assignment owner. If the context user is the assignment owner we can load status assignments, for the context user, that includes the assignments for other resources. This really is not intuitive because all these assignments appear to be assignments for the context user when really they include assignments for other resources.

0

I've created an UserVoice entry to add support to create, read, update and delete other user's task and timesheets data with CSOM (timephased Statusing and Timesheeting).

Please vote here:

https://microsoftproject.uservoice.com/forums/218133-microsoft-project/suggestions/32981722-impersonation-support-for-csom-to-read-other-user

Thanks, John

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.