Taha Ahmad
Taha Ahmad

Reputation: 559

MS Project VSTO: Faster way to read resource assignments

I want to be able to read the resource assignments (for each day) for a task in MS Project using VSTO

MS Project VSTO gives us the TimeScaleValues API that lets us read resource assignments for a task. We can then use a loop to iterate over each day.

The problem with this is that for WBS where each task has a starting and ending date spanning many months, it causes a massive slowdown (lots of days to iterate x tasks x # of resources per task).

I was wondering if there is a faster API to read back all the assignments, which would, maybe give me back the hours assigned on each day for a resource for a given task, as a comma-separated list?

Upvotes: 1

Views: 480

Answers (1)

Andrew - Eversight Ltd
Andrew - Eversight Ltd

Reputation: 347

I think you're using the only available APi to do what you need, but here's a couple of tips (which you may already be doing) to optimise performance:

  • Before you loop through all the assignments against a task, check that that the value you want to analyse (say the work value for example) is not zero for that task. If it is zero, then you don't need to loop through the individual assignment.
  • Before you get the timephased values for an assignment , check that the assignment.work is not zero. If it is zero, then you know all the timephased values will also be zero, so no need to loop through the timescaled values.
  • Ensure that you're timephasing between the assignment start and end dates. This will minimise the number of periods which the API is looping through.

Having optimised it as much as possible, I still find it is a slow job, so I make sure there's a progress bar/status updates to keep the user informed while its executing.

Not the answer you were looking for, but I hope it helps.

Upvotes: 1

Related Questions