Steve529895

I have created a sequential workflow in Visual Studio 2005, and the tasks are created inside the workflow (CreateTask), and then updated from a custom ASPX form. The problem is that the OnTaskChanged event does not execute when the task is updated.This was working OK, but now it does not fire. The Task is definitely updated, since I change the status and add comments. Further, I also found that if I change the task inside SharePoint UI, then the OnTaskChange code is run.

I did check the Logs, and found the following error message. Is it possible that the SharePoint server and Workflow engine are out of synch I have restarted the server, but still the problem remains.

I would appreciate any suggestions to resolve this.

04/11/2007 11:45:55.24 w3wp.exe (0x17DC) x1590 Windows SharePoint Services General

ERROR: request not found in the TrackedRequests. We might be creating and closing webs on different threads.
ThreadId = 6, Free call stack = at Microsoft.SharePoint.SPRequestManager.Release(SPRequest request) at Microsoft.SharePoint.SPSite.Close()
at Microsoft.SharePoint.SPSite.Dispose()
at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange, AssocType atyp)
at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange)
at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.ItemAdded(SPItemEventProperties properties)
at Microsoft.SharePoint.SPEventManager.RunItemEventReceiver(SPItemEventReceiver receiver, SPItemEventProperties properties, SPEventContext context, String receiverData)
at Microsoft.SharePoint.SPEventManager.RunItemEventReceiverHelper(Object receiver, Object properties, SPEventContext context, String receiverData)
at Microsoft.SharePoint.SPEventManager.<>c__DisplayClass8`1.<InvokeEventReceivers>b__0()
at Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state)
at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, Boolean bResetContext, WaitCallback code, Object param)
at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, CodeToRunElevated code)
at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](SPUserToken userToken, RunEventReceiver runEventReceiver, Object receivers, Object properties, Boolean checkCancel)
at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](Byte[] userTokenBytes, RunEventReceiver runEventReceiver, Object receivers, Object properties, Boolean checkCancel)
at Microsoft.SharePoint.SPEventManager.HandleEventCallback[ReceiverType,PropertiesType](Object callbackData)
at Microsoft.SharePoint.Utilities.SPThreadPool.WaitCallbackWrapper(Object state)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state) , Allocation call stack (if present) null



Re: SharePoint - Workflow OnTaskChange is not running

Simon Doy

Steve,

Just a thought has the CreateTask and OnTaskChange activity got the same colleration token specified for the task

Regards

Simon






Re: SharePoint - Workflow OnTaskChange is not running

Steve

Hi Simon,

Yes. They share the same token, and I checked they are at the same scope. But you are correct, this is the connection between the task and onchange handler. I will create a more simple workflow to determine if the problem is inside my WF, or an external factor. I will let you know the result.





Re: SharePoint - Workflow OnTaskChange is not running

Simon Doy

Steve,

I have seen this before with one of my workflows but I also had a problem with my development environment. After I updated my environment the problem disappeared. Not that I think they are related - but thought I'd mention just in case.

Simon






Re: SharePoint - Workflow OnTaskChange is not running

herve.delannoy

Hello
I have the same problem...

I tried to build my own workflow with aspx initiation and association forms. My workflow is just composed by an activity : a createTask Activity. Association form works fine, but i never see the instanciation form... And the create task activity makes an error. See below the code and the logs.

Could anyone help me thanks a lot for any answer !

Code Snippet

workflow.xml :
...
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Workflow
Title="Demo Sample"
Name="WF Sample"
Description="Demo Sample Description."
Id="A475....525763"
CodeBesideClass="WF_Test.Workflow1"
CodeBesideAssembly="WF_Test, Version=3.0.0.0, Culture=neutral, PublicKeyToken=d2e8f...66bdb1"
AssociationUrl="../_layouts/work/assoc_form.aspx"
InstantiationUrl="../_layouts/work/inst_form.aspx"
>
<Categories/>
</Workflow>
</Elements>




Logs :

Code Snippet

System.InvalidOperationException: Correlation value on declaration "workflowToken" is already initialized.
ERROR: request not found in the TrackedRequests. We might be creating and closing webs on different threads.


Element of answer are here :
http://forums.microsoft.com/TechNet/ShowPost.aspx PostID=1553658&SiteID=17&mode=1




Re: SharePoint - Workflow OnTaskChange is not running

Praveen battula

make sure that workflow correlation token and create task correlation token are different

for create task, correlation token needs to be created, but not workflowToken

thanks
praveen





Re: SharePoint - Workflow OnTaskChange is not running

Anonymous

Hello,

I've got the same problem than Steve....

It's not a correlation token problem because my workflow works well when I made my tasks modifications using Sharepoint UI!

However, as soon as I'm trying to update my task using specific code outside "Workflow code", the event OnTaskChanged is not fired....

Many thanks for your help!





Re: SharePoint - Workflow OnTaskChange is not running

Rodrigo Diaz

I had the same issue but I've resolved it using the SPWorkflowTask.AlterTask() method and not the SPWorkflowTask.Update() itself.

Hope this help!





Re: SharePoint - Workflow OnTaskChange is not running

CDam

Hello,

Unfortunately, I've already tried to use SPWorkflowTask.AlterTask() instead of Update() method....

and it hasn't worked....

Looking for others solutions...

Thanks





Re: SharePoint - Workflow OnTaskChange is not running

KevinHou

I'm also getting this error. However, my workflow is even simpler than those described here. My workflow has a createTask activity and a Code activity, and a logToHistoryListActivity activity. The workflow compeletes successfully but this error is still in the log files. Anyone know why

Thanks,
Kevin





Re: SharePoint - Workflow OnTaskChange is not running

Praveen battula

make sure that in your designer.cs class workflow token defined twice or initialized twice.

thanks
praveen





Re: SharePoint - Workflow OnTaskChange is not running

KevinHou

Praveen,

Thanks for helping me. I looked in my designer.cs file and found only one reference to my workflow token:

correlationtoken2.Name = "workflowToken";

How or where do I define it a second time as you suggest. Also, this is designer generated code, if it needs to be in there twice, shouldn't the designer do it for me

Kevin





Re: SharePoint - Workflow OnTaskChange is not running

Maycon Carrazedo

Hi,

IĄ¯m having this problem with a State Machine Workflow, the token is the same to the Create Task and OnTaskChanged actions, but the workflow just finish without erros in the WSS, instead of wait the task change.

// Code that create the Token and assing in the CreateTask action

correlationtoken4.Name = "AnaliseJuridicoToken";

correlationtoken4.OwnerActivityName = "stateAnaliseJuridico";

this.createTaskWithContentType1.CorrelationToken = correlationtoken4;

// Code that assing the Token tho the OnTaskChanged

this.onTaskAJChanged.CorrelationToken = correlationtoken4;

Even if I change the Initial State to another one, the problem persist.

Any idea

TankĄ¯s.





Re: SharePoint - Workflow OnTaskChange is not running

RoDo777

I had the same problem.

And my mistake was, to create different correlationTokes for the task.

I've done this because i choose the wrong OwnerActivityName at OnTaskChanged.

( i choose ActEvtDrivenOnTask01Changed instead of the top WF activity WF02)

When I wanted to compile i got "The correlation token for Activity createTask01 has an

owner activity name which is not its parent".

So I created another one.

If you choose the name of the WF itself in OwnerActivityName for both then everything is fine again

:-)