none
How to add custom field to the task via CSOM? RRS feed

  • Question

  • Hello!

    I'm trying to add custom fields to my programmatically created task in project 2013. Tasks are created. Then I get them and load custom fields by:

    DraftProject projCheckedOut = tstProj.CheckOut();
    projContext.Load(projCheckedOut.Tasks);
    projContext.ExecuteQuery();
    
    foreach (var task in projCheckedOut.Tasks)
    {
    	projContext.Load(task.CustomFields);
    	projContext.ExecuteQuery();
    }

    But the each CusomFieldCollection object has only 1 field (Health, because it have a default value and created automatically). But when I load my project in Project professional i saw more than 1 field, but they are empty.

    Then I tried to add a new custom field to each CusomFieldCollection of each task.

    var newField = new CustomFieldCreationInformation();
    newField.FieldType = CustomFieldType.TEXT;
    newField.Name = "F_1";
    newField.Description = "test description";
    task.CustomFields.Add(newField);
    task.CustomFields.Update();

    New field added to the collection, but when I update the project and publish it nothing is happened.

    How to add a custom field to the each task and set it value?

    Or how to attach enterprise task custom field to my tasks.

    I'm using Microsoft.ProjectServer.Client.


    Thursday, February 13, 2014 8:19 AM

All replies