<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

SharePoint 3-State Workflow Trap

Published on
9,844 Points
3,644 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

Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Join & Write a Comment

Check How effective MS Exchange Expert thinks Exchange Mailbox Recovery by SysTools IS. Visit the Official site to get detailed information:- https://www.systoolsgroup.com/exchange-recovery.html (https://www.systoolsgroup.com/exchange-recovery.h…
There are many cases found where ScanPST.exe fails to repair corrupt Outlook PST File. When user tries to repair PST using Inbox Repair tool and it throws below error: •      Inbox Repair tool does not recognize the file •      ScanPST.exe hangs in betwee…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month