Baly

Hi,

I am having CreateTask,OnTaskCreated,OntaskChanged,OnTaskCompleted inside a sequence Activity which is inside While loop.

Everything works fine for me !!

Inside the OnTaskCreated , I am updating a DocLib (for which the WF is running) Task column in order to set the link to EditTask page with the latest TaskItemId

private void OnTaskCreated(object sender, ExternalDataEventArgs e)

{

int myTaskID = onTaskCreated1_AfterProperties1.TaskItemId;

workflowProperties.Workflow.ParentItem["Task"] = workflowProperties.WebUrl + "/Lists/Tasks/EditForm.aspx ID=" + myTaskID.ToString() + ", "+" MyTask" ;

workflowProperties.Workflow.ParentItem.SystemUpdate();

}

As i said above Everything works fine But Sometimes the latest TaskItem ID is not being updated as may be the OnTaskCreated is not firing. When I am checking Logs....its showing following Exception for such case.

I am not sure what is the problem over here. Is these a bug in OnTaskCreated Activity

Engine RunWorkflow: System.Workflow.Activities.EventDeliveryFailedException: Event "OnTaskCreated" on interface type "Microsoft.SharePoint.Workflow.ITaskService" for instance id "bf3a33ec-9b5c-4121-b51b-0106c3749698" cannot be delivered. ---> System.Runtime.Serialization.SerializationException: Cannot get the member 'OnTaskCreated_MathodInvoking'. at System.Reflection.MemberInfoSerializationHolder.GetRealObject(StreamingContext context) at System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder) at System.Runtime.Serialization.ObjectManager.DoFixups() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream) at System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity, IFormatter formatter) at System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity) at System.Workflow.Runtime.Hosting.WorkflowPersistenceService.RestoreFromDefaultSerializedForm(Byte[] activityBytes, Activity outerActivity) at Microsoft.SharePoint.Workflow.SPWinOePersistenceService.LoadWorkflowInstanceState(Guid instanceId) at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance) at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance) at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId) at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs) --- End of inner exception stack trace --- at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs) at Microsoft.SharePoint.Workflow.SPWinOETaskService.RaiseEvent(SPWinOeWorkflow workflow, SPWorkflowEvent workflowEvent, Object workItem, IPendingWork.workHandler) at Microsoft.SharePoint.Workflow.SPWinOeHostServices.Send(SPWinOeWorkflow winoeworkflow, SPWorkflowEvent e) at Microsoft.SharePoint.Workflow.SPWinOeEngine.RunWorkflow(Guid trackingId, SPWorkflowHostService host, SPWorkflow workflow, Collection`1 events, TimeSpan timeOut)



Re: SharePoint - Workflow Bug in OnTaskCreated Activity ??

Baly

Further to the above , Now what I've observed that SOMETIMES OnTaskCreated Activity is not firing . and when I press F5 on my DocLib page still the column is nt getting updated as that code is inside OnTaskCreated Mathod. But interstingly after 5-6 minnuts when Refresh the same page , the column is getting updated. I have no clue about this behaviour :-(

Please help me if anyone has clues....





Re: SharePoint - Workflow Bug in OnTaskCreated Activity ??

Aaron A

I'm sure you've already checked your correlation tokens, but that doesn't seem to be the issue here...

Can you post the code of your task activities (all of them: createTask, onTaskCreated, onTaskChanged, TaskCompleted). Perhaps we can find something in there that's blowing it up. I want to say my problem was a timer issue, because my code stepped through like it should have, but SharePoint threw errors. Since I never resolved the original problem, I'll try my best to help, but as I had said I found a workaround, so maybe we can do the same in your case.

Aaron





Re: SharePoint - Workflow Bug in OnTaskCreated Activity ??

Baly

Dear Aaron,

I am having the ECM CollectFeedBack example . The only difference is that I m having CreateTaskWithContentType,OnTaskCreated,OntaskChanged,CompleteteTask inside a while loop. one more thing which I am doing is I am updaing workflowProperites.Item[someColumn] inside CompleteTask as well as in OntaskChange. The problem still persists





Re: SharePoint - Workflow Bug in OnTaskCreated Activity ??

Aaron A

have you tried attaching to the workflow process and debugging It might take you to the exception that is getting thrown.




Re: SharePoint - Workflow Bug in OnTaskCreated Activity ??

tlingenf

Wow, I'm experiancing a problem with this same exact senario. I have CreateTask, OnTaskCreated, OnTaskChanged, and CompleteTask all contained within a SequenceActivity contained within a WhileActvity. While attaching to the debugger and stepping through the code, the second time through the while loop it will never get to the OnTaskCreated activity and does not throw an error or a Workflow Fault. Furthermore, the workflow history adds two items that state failed to run. Like Baly states in his workflow, I wait about 5-6 minutes and it looks like it recovers, but not always.

If I disable the OnTaskCreated activity, everything works fine without a problem. As soon as I renable the activity the problem returns. I do not have any code associated with the OnTaskCreated activity Invoked Handler because I am just interested int the AfterProperties so that I can obtain the TaskItemId in a subsequent activity.

I also have begun to wonder if there is a bug with the OnTaskCreated activity. If this were true, it would not be the first activity with a bug, there was a previous bug with the delay activity that has since had a patch released.





Re: SharePoint - Workflow Bug in OnTaskCreated Activity ??

Aaron A

You may check to see if the values are pulling in correctly from the task form...make sure the form is setup correctly.





Re: SharePoint - Workflow Bug in OnTaskCreated Activity ??

spardo

Has anyone reached any resolution to this issue Does the SP Workflow team know about this Any news would be greatly appreciated.






Re: SharePoint - Workflow Bug in OnTaskCreated Activity ??

Baly

It seems that this is the Bug with the OnTaskCreated activity as we debugged and check all the things but couldn't find the cause of error.

But Good news is that...We found one work-around for this issue....with the following 2 steps !!!

-->We disabled the OnTaskCreated activity

--> Developed an Event Handler and attached it to the ItemAdded event of the TASK List to get the newly added task ID and update the form library TaskURL column.

Now it is working perfectly





Re: SharePoint - Workflow Bug in OnTaskCreated Activity ??

Vikramg

Hi Baly

I am struggling with it since morning. The event fires randomely . I dont think it is code or task tokens related.

The requirement that I have is to remove existing users ( remove Inheritence) and add different users to the List Item that has been created and i am using the on Task created event to do this but this one is not consistent at all. Fires almost 1 in 3 times. I am Clueless on what is going on.

Can you share with me about the workaround that you came up with .I would like to not to use OnTaskCreated if possible for the above requirement

private void SupervisorApprovalAfterTaskCreated_Event(object sender, ExternalDataEventArgs e)

{

SPListItem ListItem = workflowProperties.TaskList.GetItemById(ApproverTaskProperties_After.TaskItemId);

TaskListAddRemovePermissions(ListItem, ItemApprover);

}

Thanks In advance

Vikram





Re: SharePoint - Workflow Bug in OnTaskCreated Activity ??

Baly

Hi Vikram,

Since the OnTaskCreated is giving problems, I would suggest to invoke TaskListAddRemovePermission() from a Event Handler . You can attached the Event Handler to the Task-List on the ItemAdded event and get the latest task ID.

-Baly