wjzhang

HelloSmile,

I have encountered a problem when I try to deploy the sharepoint workflow to the client's MOSS. The workflow failed to started because of the following reason:

Operation is not valid due to the current state of the object.

I'm sure that ths wf code is correct. This error is generated when executing SPSite.WorkflowManager.StartWorkflow. These codes are written in infopath form, the FormSubmit_Event. Here are my codes: (test is the name of a form library)

SPSite site = new SPSite("http://moss2007/workflowcenter/site1/");
string fileurl = "
http://moss2007/workflowcenter/site1/test/file01.xml";

SPList list = site.RootWeb.GetList("http://moss2007/workflowcenter/site1/test");
SPListItem item = site.RootWeb.GetListItem(fileurl);

SPWorkflowAssociation wa = list.WorkflowAssociations.GetAssociationByName(
"myworkflow", System.Globalization.CultureInfo.CurrentCulture);

String eventData = GetInitiateXmlString();
wa.AssociationData = eventData;
site.AllowUnsafeUpdates = true;
site.RootWeb.AllowUnsafeUpdates = true;
site.WorkflowManager.StartWorkflow(item, wa, eventData); // errors generated here

Have anyone got a solution Thanks!




Re: SharePoint - Workflow StartWorkflow Error

Paul Galvin

I would try putting a site.Update() just before attempting to start the workflow.






Re: SharePoint - Workflow StartWorkflow Error

wjzhang

hello Paul,

Thank you for your suggestion. But the method you recommended (site.Update()) does not exist. I tried site.RootWeb.Update() before starting my workflow. Still the problem exists and the error message the same as I encountered earlier. (Operation is not valid due to the current state of the object.)