none
Not persisting state for request due to previous errors. SharePoint 2010, .NET workflow RRS feed

  • Question

  • Enviornment: SharePoint 2010, Custom approval workflow built in C#, simple Task Edit form in InfoPath (Solution screenshot below)

    Problem: I modified (just one method) in the workflow C# code and build and deployed the wsp using Update-SPSolution powershell. After the deployment, the new instance of the workflow work fine and tasks are getting approved and workflow is being Completed. BUT the old "In Progress" workflows are not moving ahead, the tasks are not getting approved/rejected. Then I tried to revert back to the old wsp but still the same result. I missed versioning the workflow code for modification (as per this msdn article). 

    From what I understand, the "persisted workflow instance" which is stored in the content database is messed up after the deployment and hence the old workflows are not able to recognize the new dlls. Below are the 2 errors I get in the ULS when I try to take action (Approve/Reject) a task on the "old" In Progress workflows. I am already 5 days on this PRODUCTION issue. Any advice to fix this problem and get the old workflows working? Its very critical and urgent.

    Errors in ULS:

    1) Not persisting state for request due to previous errors. Form Template: urn:schemas-microsoft-com:office:infopath:TaskFormV1:-myXSD-2012-06-08T15-10-32

    2Form databind failed, due to a WSS exception: This task is currently locked by a running workflow and cannot be edited.

    


    Please mark as 'Propose as Answer' or 'Vote' as appropriate.

    • Edited by Sagir Kazi Wednesday, February 25, 2015 6:39 PM
    Wednesday, February 25, 2015 3:38 PM

Answers

  • Finally here is the solution that worked for me. I was able to revert back to my old stable state using the old wsp which was deployed before. Below are the steps.

    1. Deploy the old wsp using Update-SPSolution powershell. Make sure that the old dll is deployed correctly in assembly folder. Also make sure that the wsp (and the dll within) is the right one with which these workflows were started.
    2. Do an IISRESET on all servers in the farm
    3. Do a restart of the SharePoint Timer service on all servers in the farm

    Once the deployment is rolled back, we still need to fix the old tasks of the already "In Progress" workflows, which we tried to take action (Approve/Reject) but dint work because of the new deployment. For all these tasks the "Workflow Version" property is NOT equal to 1. We would have to reset them back to 1 so that the user can retry and take action on those tasks to move the workflow forward. Below is the code that I used in the command line utility. "args" are the input parameters to the utility.

                using (SPSite site = new SPSite(args[0]))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList list = web.Lists.TryGetList(args[1]);
                        SPListItem originalTask = list.GetItemById(Convert.ToInt16(args[2]));
    
                        Console.WriteLine("Workflow Version: " + originalTask["Workflow Version"].ToString());
    
                        originalTask["Workflow Version"] = 1;
                        originalTask.SystemUpdate();
                        Console.WriteLine("Workflow Version reset to 1");
                    }
                }
    Hope this helps someone.


    Please mark as 'Propose as Answer' or 'Vote' as appropriate.

    • Marked as answer by Sagir Kazi Thursday, March 5, 2015 5:43 PM
    Thursday, March 5, 2015 5:42 PM

All replies

  • Hi Sagir,

    I recommend to check the actions set in “When a Task is Pending” step to see if any steps have not been executed.

    If yes, we cannot complete the tasks by approving or rejecting the task until the steps have been executed.

    If that is the case, we need to modify the steps in the workflow to make sure those steps can be executed.

    Here is a similar thread for your reference:

    https://social.msdn.microsoft.com/Forums/en-US/68181453-cc8b-43c0-81a9-dd78b8bcc24f/sharepoint-designer-workflow-task-gets-locked-please-help

    Thanks,
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Victoria Xia
    TechNet Community Support

    Thursday, February 26, 2015 9:29 AM
    Moderator
  • Hi Victoria,

    This is not a SharePoint Designer workflow but custom VS. I dont have "When a Task is Pending" action set.


    Please mark as 'Propose as Answer' or 'Vote' as appropriate.

    Thursday, February 26, 2015 2:23 PM
  • Hi Sagir,

    What are the whole steps in your VS workflow?

    If you run the old workflow, can the tasks created be completed?

    Thanks,
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Victoria Xia
    TechNet Community Support

    Friday, February 27, 2015 1:56 AM
    Moderator
  • Hi Victoria,

    The old tasks that were already created in the "In Progress" workflows BEFORE the new deployment are NOT working. All new tasks created by after the deployment are working fine and can be completed. 

    The workflow code is huge and has Activities and other stuff and was created as per the guidelines from the Microsoft site. 

    My question is: Why are the new instance (and tasks) of the workflow are working fine but not the old one? How can we identify the issue and fix it.


    Please mark as 'Propose as Answer' or 'Vote' as appropriate.

    Friday, February 27, 2015 2:50 PM
  • Hi Sagir,

    Per my research, the issue may be due to the number of the workflows run at the same time has exceeded the Event delivery throttle value which is by 15 by default.

    To avoid such issue in the future, you may need to increase the Event delivery throttle value by using Stsadm commad: stsadm -o setproperty -pn workflow-eventdelivery-throttle -pv <A valid integer>.

    For the tasks which have been locked, you can use the code below to unlock them:

    foreach (SPWorkflowTask task in tasks)
    {
        if (task[SPBuiltInFieldId.WorkflowVersion].ToString() != "1")
        {
            task[SPBuiltInFieldId.WorkflowVersion] = 1;
            task.SystemUpdate();
         }
    }
    

    More references:

    http://blogs.msdn.com/b/vincent_runge/archive/2008/09/16/about-the-workflow-eventdelivery-throttle-parameter.aspx

    https://technet.microsoft.com/en-us/library/cc287939(v=office.12).aspx

    Thanks,
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Victoria Xia
    TechNet Community Support

    Monday, March 2, 2015 2:20 AM
    Moderator
  • Hi Victoria,

    The system is not heavily used and there is very little load on the system. I also checked if there is any pending Batch in the database that needs to be processed but there are none (see screenshot below). I don't think we are even near from hitting the threshold value.


    Please mark as 'Propose as Answer' or 'Vote' as appropriate.

    Monday, March 2, 2015 8:43 PM
  • Hi Sagir,

    If so, I recommend to use the code to unlock the tasks and then check if the tasks can be completed.

    foreach (SPWorkflowTask task in tasks)
    {
        if (task[SPBuiltInFieldId.WorkflowVersion].ToString() != "1")
        {
            task[SPBuiltInFieldId.WorkflowVersion] = 1;
            task.SystemUpdate();
         }
    }
    Thanks,
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Victoria Xia
    TechNet Community Support

    Tuesday, March 3, 2015 10:30 AM
    Moderator
  • Thanks Victoria for all your support. I did try to check and update the Workflow Version for the tasks. All the tasks are unlocked (value 1) but still no progress. One thing that I would like to mention is that when I take action on any task then the Workflow Version of that task is updated to 512 or 1024 or something similar but the task status is still "Not Started".

    What I feel is that the tasks are unlocked but the task actions are somehow NOT connected to the workflow instance and hence when any action happens, the task is not able to find/communicate the appropriate workflow instance and move it forward. Let me know what you think.


    Please mark as 'Propose as Answer' or 'Vote' as appropriate.

    Tuesday, March 3, 2015 1:35 PM
  • Hi Sagir,

    You are right.

    As you used Update-SPSolution command which would cover the original solution, so the tasks lost the association with the workflow instance.

    Then you reverted back to the old wsp, however the association had already been deleted.

    So you may need to re-run the workflow instances to re-create the tasks.

    Thanks,

    Victoria


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.


    Wednesday, March 4, 2015 5:18 AM
    Moderator
  • Finally here is the solution that worked for me. I was able to revert back to my old stable state using the old wsp which was deployed before. Below are the steps.

    1. Deploy the old wsp using Update-SPSolution powershell. Make sure that the old dll is deployed correctly in assembly folder. Also make sure that the wsp (and the dll within) is the right one with which these workflows were started.
    2. Do an IISRESET on all servers in the farm
    3. Do a restart of the SharePoint Timer service on all servers in the farm

    Once the deployment is rolled back, we still need to fix the old tasks of the already "In Progress" workflows, which we tried to take action (Approve/Reject) but dint work because of the new deployment. For all these tasks the "Workflow Version" property is NOT equal to 1. We would have to reset them back to 1 so that the user can retry and take action on those tasks to move the workflow forward. Below is the code that I used in the command line utility. "args" are the input parameters to the utility.

                using (SPSite site = new SPSite(args[0]))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList list = web.Lists.TryGetList(args[1]);
                        SPListItem originalTask = list.GetItemById(Convert.ToInt16(args[2]));
    
                        Console.WriteLine("Workflow Version: " + originalTask["Workflow Version"].ToString());
    
                        originalTask["Workflow Version"] = 1;
                        originalTask.SystemUpdate();
                        Console.WriteLine("Workflow Version reset to 1");
                    }
                }
    Hope this helps someone.


    Please mark as 'Propose as Answer' or 'Vote' as appropriate.

    • Marked as answer by Sagir Kazi Thursday, March 5, 2015 5:43 PM
    Thursday, March 5, 2015 5:42 PM