I'm developing sequential workflow for Sharepoint 2010. It starts at item creation and it has activities as follows: onWorkflowActivated, then createTaskWithContentType and onTaskChanged in while loop. onWorkflowActivated1 is bounded to field workflowProperties of type SPWorkflowActivationProperties, initialized with default constructor inline. createDraftTask in its MethodInvoking set tasks AssignedTo property with value retrieved from items field of type SPUser, on which the workflow was started. The problem is that all item fields except one (of type Choice) are null while running the workflow for the second and every next time, i.e. while creating second item on the list, which triggers another run of the workflow, workflowProperties.Item["fieldname"] is null, even though in web browser all values are visible and set. For the first item created on the list, it all seems fine. Code for retrieval items field is as usual:
object fieldValueFromGuid = workflowProperties.Item[ProcedureItem.ProcessOwnerFieldId];
object fieldValueFromWorkflowProperties = workflowProperties.Item["ProcessOwner"];
// this works usually when debugger is attached, in development environment
object fieldValueFromList = workflowProperties.List.GetItemById(workflowProperties.ItemId)["ProcessOwner"];
No matter if I use fields GUID or name in the indexer, both are null. Usually in the development environment, when debugger is attached, the third approach works. Any ideas what might be the reason? Thanks in advance for all suggestions