Sharepoint – Error in SPWorkflowTask.AlterTask Method

Recently I was working on a Sharepoint workflow.
We had to raise an event from our application form, which would trigger the eventHandler. We had used “OnTaskChange” event for that respective task in the workflow.
There were four different conditions on the “OnTaskChange” event which were segregated based on the If-Else condition.
It such happened that I was able to execute the first three conditions. The control was going to the workflow from the Application page, and I was able to debug the flow and the If-Else conditions as well.
But when I raised the fourth condition, It was not getting executed. After debugging I found that It is not reaching the workflow either.
It was giving “Object reference not set to an instance of an object” error on the


Method. The method basically accepts three parameters,
1. The Task Item
2. HashTable
3. Synchronisation Flag

Interestingly none of the three parameters were Null. Even after searching on the internet, I couldn’t get a break through. I checked the correlation token being set for the task on creation and the one passed “OnTaskChanged”.
After spending a lot of time, one of my colleague told me to check for the values being passed in the HashTable. That was it. Before executing the AlterTask method, the Workflow runtime checks the items in the workflow. If it finds any of the Item from the Hashtable missing, it does not allow the AlterTask method to execute.
In my case too, I was passing a null value for one of my flag, which  was getting checked in the workflow. After setting the flag, the workflow started working as expected.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s