After spending way too many hours messing with this, I got it to work. I was trying to update the Assigned To in a Form Library (also works in a Document Library) using a Workflow in Visual Studio 2008. SharePoint being SharePoint, nothing is ever easy.
In the VS I created a Sequential Workflow. Then I added a Code activity (codeActivity1) to the design. After that, double click codeActivity1 in the design window.
Create the Public variable wfP:
Public wfP As SPWorkflowActivationProperties = New Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties
Then add the following code to your codeActivity1 module.
Dim site As SPWeb = New SPSite(wfP.WebUrl).OpenWeb()
Dim list As SPList = site.Lists(wfP.List.Title)
Dim listItem As SPListItem = wfP.Item
listItem(“Assigned To”) = site.Groups(“gLeads”)
listItem.Update()
It should look like this when you are done:
Private Sub codeMoveToLead_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim site As SPWeb = New SPSite(wfP.WebUrl).OpenWeb()
Dim list As SPList = site.Lists(wfP.List.Title)
Dim listItem As SPListItem = wfP.Item
listItem(“Assigned To”) = site.Groups(“gLeads”)
listItem.Update()
End Sub
Trying to set the .AssignedTo never worked for me.