1

I'm trying to update the duration field on tasks using CSOM, but the following is happening. If the task already has a duration value, then CSOM sets the new value without a problem. But if the task still doesn't have a value, then the new value added by CSOM, doesn't get saved.

This is my data:

enter image description here

For instance, if in the code I set the value of task "dois" to "2.00" then on the project schedule, I'll see "2d". However, if I in the code I set the value of "um" to "5.00", then when I check the schedule again, the duration field for "um" will still be blank. Furthermore, when I'm reading the duration value for "um" using CSOM, the value is actually "1d" and not blank as it appears on the project schedule.

Any ideas?

2 Answers 2

1

This behaviour is not meet me before , but I will try to mention some hint to investigate and solve your issue:

  • Instead of updating the duration try to set the start date and end date and check if the duration field calculated correctly ,

  • Then check in your code How you add duration field , it should be a duration data type.

  • Also, check the type of scheduling is it auto schedule or manual schedule, it should be Auto.

  • Regarding "when I'm reading the duration value for "um" using CSOM, the value is actually "1d" and not blank" it's not mean you update it correctly. I think it's the default value of the duration field so try to add duration from code as 2 days and check also the retrieving value.

4
  • - it does. But I want to be able just set a duration without any start or finish date. As you can see by my picture, if it's possible on the project schedule, it should be able to do the same through CSOM. - I believe you're referring to DurationTimeSpan, but the field I've been using to set the duration is actually this one, which is a string: msdn.microsoft.com/en-us/library/office/… Jul 29, 2016 at 15:00
  • - it's on manual scheduling, yes. Jul 29, 2016 at 15:00
  • - that's what I did, but it doesn't pick up the new value. I just said that the duration on the task is 1d before I update it. Jul 29, 2016 at 15:02
  • Dear @sedulam I am sorry I write it manual by wrong but I mean auto so I update it, and Good to hear that the issue has been solved , Good Luck :) Aug 2, 2016 at 12:05
0

I got the answer from the MS Project forums: https://social.msdn.microsoft.com/Forums/en-US/b630513a-90eb-4a2a-9365-add100ff1b06/cant-set-duration-field-on-new-task-using-csom?forum=project2010custprog

Your problem is related to manual mode tasks. If you used Automatically Scheduled Tasks then the problem wouldn't occur. Manual mode should only be used for initial high level "I've no idea how long this will take" pictures. After that default auto.

You could try setting [Scheduled Duration] instead, but I still recommend not using Manual mode..

1
  • 2
    Can you please put the answer in writing here to, so that it will be helpul to future readers even if that link breaks? Aug 1, 2016 at 10:14

Your Answer

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

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