<

SharePoint 3-State Workflow Trap

Published on
9,759 Points
3,559 Views
2 Endorsements
Last Modified:
Approved
I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflows available "Out-of-the-Box") to the Wiki Library".

Looks like a good idea for business users, especially if they need to control wiki content contribution. I have to mention that their department use small isolated SharePoint farm based on MOSS 2007 Standard.

As usual, I sent her simple step-by-step manual from the MS TechNet (or someone’s blog article, I don't remember the exact source).

She has successfully attached workflow to the library, assigned column with state values, and managed to start the workflow without any problems. Although all the workflow instances she started have never been finished successfully. That became interesting for me so I visited her servers myself. After some diving into logs I found the following exception:

System.ArgumentException: Value does not fall within the expected range.     
at Microsoft.SharePoint.SPFieldCollection.GetField(String strName, Boolean bThrowException)     
at Microsoft.SharePoint.SPListItem.GetValue(String strName, Boolean bThrowException)     
at Microsoft.SharePoint.SPListItem.GetValue(String strName)     
at Microsoft.SharePoint.SPListItem.get_Title()     
at Microsoft.SharePoint.Workflow.Application.IssueTracking.OnWorkflowActivated(Object sender, EventArgs e)    
at System.Workflow.ComponentModel.Activity.RaiseGenericEvent[T](DependencyProperty dependencyEvent, Object sender, T e)     
at System.Workflow.Activities.HandleExternalEventActivity.RaiseEvent(Object[] args)     
at System.Workflow.Activities.HandleExternalEventActivity.Execute(ActivityExecutionContext executionContext)     
at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)     
at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)     
at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)     
at System.Workflow.Runtime.Scheduler.Run()

Open in new window

Well, let's see...
Looks like Microsoft.SharePoint.SPListItem.get_Title()  is a root of evil. I opened SharePoint DLL with a Reflector (pretty useful tool, especially for SharePoint specialist) and found the following code:
 
public string get_Title()
{
    object obj2 = this.GetValue("Title");
    if (obj2 != null)
    {
        return (string) obj2;
    }
    return string.Empty;
}

Open in new window


Gotcha! There is no "Title" column in a default Wiki template. And reference to this column is perfectly hardcoded to the 3-State workflow code. Actually not sure why. Thus we just added a new column with this name and now it works well... Although we never assign any value to that field, you probably want to set something more meaningful, so you can create Title field as calculated and use formula to grab page name or any existing data.

At least she hasn’t contacted me again on this :)

PS : Please note that you can meet the same issue when you try to attach OOTB 3-State workflow to the Library with no "Title" column!

Hope you find this Article helpful - and dont forget to vote :)
2
Comment
0 Comments

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Join & Write a Comment

In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month