Removing Extra Workflow Status Column in Default View

When SharePoint starts a workflow on a list for the first time, it has this annoying behavior of adding a workflow status column to the default view of the list.  Often times, this information is of no practical use for end users.  Unfortunately, there appears to be no way of getting rid of this behavior.  So instead, you have to either remove it by hand after the first instance has started, or write custom code.  Luckily the code is fairly simple and can be placed anywhere you want, including inside of a custom code activity within the workflow that is started.

Here's the type of code you need:

 // In our case, the internal column name is the first 8 characters of the
// list name followed by " Workflow"
string colName = (WorkflowItemList.Title + " Workflow").Substring(0, 8);
SPView defaultView = YourList.DefaultView;
if (defaultView.ViewFields.SchemaXml.Contains("\"" + colName + "\""))
{
    defaultView.ViewFields.Delete(colName);
    defaultView.Update();
}

Note that I think the internal column name is always the first 8 characters of the list name, but if you have multiple workflows on the same list, it may be different (you may need to export your list and look at the manifest.xml to find the internal field name).  If you find it is different,  you could either hard code the column name or you could loop through all the FieldsRefs in the view and remove any that have a type of "WorkflowStatus".  In any case do not remove the Field from the SPList (this will crash your workflows!); just remove the FieldRef from the SPView.  Once it's gone, SharePoint won't try and add it back unless you remove the workflow association and add it back in.

UPDATE: the internal column name is actually the first 8 characters of the workflow name, which in our case was using the list name followed by " Workflow", but is not always the case. Change the first line in the sample code to retrieve the workflow name, or hard code the name if it is always the same in your case.

Also, one other thing I tried after this was to explicitly add the workflow status field into the list definition, copying the Field definition directly from the exported list definition manifest file, thinking that we would just preempt SharePoint and add the field ourselves, leaving it out of the default view. Alas, this did not work as SharePoint, once again, outsmarted us by adding its own field to the column and the default view.