I have a situation where a workflow attached to a list is being initiated successfully in one case but not another. My setup uses two lists, one workflow, and one event handler:
- List 1 "BizOp Announcements": this is a Sharepoint announcements list that is set up to receive email from a user whenever a new Business Opportunity comes in (the user gets the email and forwards the email to the list)
- List 2 "BizOps": this is a simple custom list with about 10 fields. Each list item represents a new Business Opportunity that our marketing team will need to see
- Workflow: I have a simple workflow attached to List 2. It creates two tasks whenever a new item is added to List 2
- Event Handler: I have an ItemAdded() event handler attached to List 1. Whenever List 1 receives an email, it adds the email to the list as a new list item...and as a result ItemAdded() is fired which uses the object model to create a new item in List 2.
We have Business Opportunities sent to us by email. Someone forwards the BizOp email to the BizOps Announcements list, which saves a copy of the email and any necessary attachments. Then the event handler for the BizOps Announcements list creates a new corresponding item in the BizOps list. This initiates the Workflow which creates two tasks for the Marketing department.
The event handler works perfectly whether I add a new item to the BizOps Announcements list directly (through the "New" menu item) or by sending an email to the list. It correctly creates a new list item in the BizOps list. However, the Workflow only gets started properly when I add the new item to the BizOps Announcements list directly (through the "New" menu item). If I send an email to the BizOps Announcements list, the new item gets created in the BizOps list but the Workflow produces an error. In this case, the workflow status column on the BizOps list shows "Error Occurred". When I debug the Workflow, it never hits any of the code breakpoints in the Workflow...as if it never even gets initiated (I am able to successfully debug and step through all the code in the Workflow when the workflow is started by adding an item to BizOps Announcements using the "New" menu item). Here is the error I'm seeing in the SharePoint ULS logs:
01/11/2007 13:08:46.46 OWSTIMER.EXE (0x08C4) 0x0D0C Windows SharePoint Services Workflow Infrastructure 72ev Medium Value cannot be null.
01/11/2007 13:08:46.57 OWSTIMER.EXE (0x08C4) 0x0D0C Windows SharePoint Services Workflow Infrastructure 88xr Unexpected WinWF Internal Error, terminating workflow Id# a8a4318a-80ef-450a-92ec-01b324c0186e
01/11/2007 13:08:46.57 OWSTIMER.EXE (0x08C4) 0x0D0C Windows SharePoint Services Workflow Infrastructure 98d4 Unexpected System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null. at Microsoft.SharePoint.Workflow.SPWorkflow.GetReservedItemId(SPList list, Guid taskId, Boolean createNew) at Microsoft.SharePoint.Workflow.SPWorkflowInstanceBase.GetReservedItemId(SPList list, Guid taskId) at Microsoft.SharePoint.Workflow.SPWinOETaskService.CreateTaskWithContentTypeInternal(Guid taskId, SPWorkflowTaskProperties properties, Boolean useDefaultContentType, SPContentTypeId ctid, HybridDictionary specialPermissions) at Microsoft.SharePoint.Workflow.SPWinOETaskService.CreateTask(Guid taskId, SPWorkflowTaskProperties properties, HybridDictionary specialPermissions) --- End of inner exception stack trac...
01/11/2007 13:08:46.57* OWSTIMER.EXE (0x08C4) 0x0D0C Windows SharePoint Services Workflow Infrastructure 98d4 Unexpected ...e --- at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, Parame...
01/11/2007 13:08:46.57* OWSTIMER.EXE (0x08C4) 0x0D0C Windows SharePoint Services Workflow Infrastructure 98d4 Unexpected ...terModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.Workflow.Activities.CallExternalMethodActivity.Execute(ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime) at System.Workflow.Runtime.Scheduler.Run()
Could this be a permissions issue...due to code running under different permissions when initiated by the received email versus by having someone add the item through the "New" menu item I can't figure out how to determine what the Null value is that is causing the problem since I can't seem to get the debugger to break anywhere in the code when the error occurs. I have even put a bunch of System.Diagnostics.EventLog.WriteEntry() calls in the workflow code to try to trace what's happening by writing to the Event Log, but they never get called (they do get called as expected when the workflow runs without errors).
Has anyone run into this problem with workflows not starting properly under this type of scenario Anyone have any suggestions on workarounds I can try Any ideas on how to get better information on the ArgumentNullException that is being thrown
By the way, the only reason I'm using two lists in my solution instead of one is that I couldn't find a way to enable a custom list to receive emails, so I had to use the Announcements list to receive the email and the event handler to add the entry to my custom list. Is it true that only some of the built-in SharePoint lists have the capability to receive email, such as Announcements lists Does anyone know how to email-enable a custom list in SharePoint

Problem using email to initiate workflow
Santhosh Pallikara
...this is a follow-up to my previous post...
I have done some more troubleshooting. I have greatly simplified the above scenario in an attempt to isolate my problem. I've narrowed it down to one list and one workflow:
A user sends an email to the list. In response to receiving the email, the list creates a new list item (this is just the built-in behavior for email-enabled lists...I didn't need write any code to make this part work).
The parts I've just described all work perfectly.
So next, I need to attach my workflow to the list. I can either set the workflow to start automatically whenever a new list item is created, or I can tell it to only start whenever a user manually starts it on an existing list item. I tested with all four of the following combinations:
The only combination that does not work is when the workflow is set to start automatically and the new list item is created by sending an email to the list. I've verified that the user sending the email has Full Permissions on the list. The error produced is the same one described in my previous post. The debugger will break within the workflow code on all of the combinations except the last one.
Any suggestions on things to try
Raulsassaa
I suspect that these two issues are related
http://forums.microsoft.com/technet/ShowPost.aspx postid=1220669&siteid=17
MattFletcher