I am developing a workflow. I have extended the Workflow Task content type with the Comments field using SharePoint UI. I need to set some value for this field in my code when editing the task, but it stays empty. Here's my code:

private void SetTaskProperties(string comment)
    Hashtable taskProperties;

    taskProperties = new Hashtable();
    taskProperties.Add(SPBuiltInFieldId.Completed, true);
    taskProperties.Add(SPBuiltInFieldId.TaskStatus, completed);
    taskProperties.Add(SPBuiltInFieldId.PercentComplete, 1.0);
    taskProperties.Add(SPBuiltInFieldId.Comments, comment);
    SPWorkflowTask.AlterTask(this.task, taskProperties, false);

Should I be using something else than SPBuiltInFieldId.Comments? I am getting the same result when updating the task directly, instead of using the Hashtable in the code above.

  • I can't check the code but I'm sure when I did this I used the alternative method of taskProperties["Comments"] = comment;, or something similar (At home can't check). Have you tried this? – Hugh Wood Nov 27 '12 at 0:18
  • I did and it doesn't work. I tried with SPBuiltInFieldId.Comments and with SPBuiltInFieldId.Comment. Did you know that there are 3 fields in SharePoint that are named Comments? This is nuts! – Boris Nov 27 '12 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.