When I tried to add task item on Sharepoint 2007 programatically I got an error mentioed that the field is maybe read only.
So....
You can not do :
item["Assigned To"] = "administrator";
item["Assigned To"] = "administrator@domain.com";
item["Assigned To"] = "domain\\administrator";
Instead, you have to specify the user ID from the user's list:
item["Assigned To"] = 1;
But how to tell what ID does a user have?
The only way I know of is using the "Users" property of the SPWeb object.
Lets say you want to assign the field to "ahmad@domain.com" (you only know the email).
you can use the following code:
item["Assigned To"] = item.ParentList.ParentWeb.Users.GetByEmail("ahmad@domain.com").ID;
Saturday, April 11, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment