Hi I have a sharepoint 2007 workflow and i need to get the SPuser object in order to send mails to the user but all i can get is a string from the task's assigned to field. How do i do this?
This is my code
foreach (SPWorkflow workflow in splistitem.Workflows)
{
foreach (SPWorkflowTask task in workflow.Tasks)
{
string user = task["Assigned To"].ToString();
}
}
string assignedToValue = task["Assigned To"].ToString();
SPFieldUserValue userField = (SPFieldUserValue)workflow.Tasks.Fields["Assigned To"].GetFieldValue(assignedToValue);
SPUser user= userField.User;
To make it more robust, you can use SPBuiltInFieldId.AssignedTo
instead of the hard-coded "Assigned To"
value.