Back to previous

Dynamically assign task to user in Sharepoint

I had to create a task dynamically in C# and assign the task to a reviewer, which is a user account. However, there was this problem of the "Assigned to" field is only read only. To do that, just create an SPFieldUserValueCollection and assign it to task item.

SPFieldUserValueCollection fv = new SPFieldUserValueCollection();
fv.Add(new SPFieldUserValue(web, web.CurrentUser.ID, web.CurrentUser.Name));
oTaskItem["Assigned To"] = fv;

ShareThis

If you think this post is useful, please recommend me at the bottom of the page. ;)

Discussion