I am new to SharePoint. Sorry if answer to my question is obvious.
I can’t understand, how to assign Task to user programmatically. I set properties in SPWorkflowTaskProperties, all properties pass to Task, but string property AssignedTo doesn’t.
//next variants don't works
TaskProperty.AssignedTo = "1;#Michael Pushin";
TaskProperty.AssignedTo = "Michael Pushin";
TaskProperty.ExtendedProperties["Assigned To"] = "1;#Michael Pushin";
I am trying to realize delegation pattern. For it I read information from list item that have field type Person.
SPList functList = thisWeb.Lists["Functions"];
SPListItem functItem = functList.GetItemById(1);
object person = functItem["Default Assignee"];
string assignee = person.ToString();
//At this point assignee equals "1;#Michael Pushin"
When I set the “Assigned To” field by hands and read programmatically it value equals to “1;#Michael Pushin” too.
How can I set “Assigned To” field programmatically from value of the person variable?
Thank you in advance.
PS: sorry for my writing. English is not my native language.
PPS: SharePoint 2010.
Do not convert person to string.
At this point person is smth like SPFieldUserValue. Cast to the actual type and see if you’re able to get SPUser out of it and then grab the SPUser.Login.