Showing posts with label workflow. Show all posts
Showing posts with label workflow. Show all posts

Wednesday, 20 November 2013

Workflow Error - Failed on Start (retrying)

If you encounter this error message "workflow error - failed on start (retrying)" in visual studio .net workflow, you can try the following solutions to fix the issue:

  • Change the Correlation Token value to be unique. The workflow and each activity should have a unique value. The workflow itself and each task you need to reference in the workflow must have a separate correlation token. Refer to this link http://msdn.microsoft.com/en-us/library/ms475438.aspx for more details. 

In the below example, I set the correlation token of the workflow in onWorkflowActivated1 to "workflowToken" and then the correlation token of the workflow task createEndorserTask to "taskToken".

correlation token

Figure 1: workflowToken


correlation token

Figure 2: taskToken



  • Check the dll in the workflow.xml (CodeBesideAssembly). It should be the same as the one in the GAC.





Thursday, 3 October 2013

Remove Workflow Column from SharePoint List View

When you attach a workflow to a SharePoint list, the workflow column will be added automatically to the default view of the list. This column shows the status of the workflow and when you click on the status, you will be redirected to the Workflow Status page. Usually, this information is of no practical use for end users therefore you don't want this column to appear in the list view. So in order to achieve it, you need to write a custom code that will remove the workflow column programmatically.


Below is the sample code of a console application that removes workflow column from the default view of the SharePoint list:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace RemoveWorkFlowColumnFromSPView
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length != 4)
            {
                Console.WriteLine("Please input parameters.");
                Console.WriteLine("Format: <site url> <list name> <view name> <workflow template name>");
                return;
            }

            string workflowColName = string.Empty;
            string siteUrl = args[0]; // "http://www.vpc.com/sites/PFW"; //
            string listName = args[1]; // "Perimeter Firewall Request"; //
            string viewName = args[2]; // "All Requests"; //
            string workflowName = args[3]; // "FirewallRequestWorkFlow"; //


            using (SPSite site = new SPSite(siteUrl))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    web.AllowUnsafeUpdates = true;

                    SPView objView = web.Lists[listName].Views[viewName];

                    //static name of the workflow column is equal to 8_character_name_of_workflow_column,
                    // without space and is case sensitive.
                    workflowColName = workflowName.Substring(0, 8);

                    if (objView.ViewFields.Exists(workflowColName))
                    {
                        objView.ViewFields.Delete(workflowColName);
                        objView.Update();

                        Console.WriteLine(string.Format("{0} column: {1} has been removed successfully from the {2} view",
                            workflowName,
                            workflowColName,
                            viewName));
                    }

                   

                    web.AllowUnsafeUpdates = false;

                   
                }
            }

           

        }
    }
}