title: Sharepoint 2010 autogenerated workflow column
body: <p>is it possible to change order of workflow autogenerated column (from last position to 2nd)? I need to do this programatically, not in Library > Modify view.</p>
  
  <p><strong>EDIT:</strong>
  Whole workflow I made in Visual Studio and it is with custom association, initiation an task form.</p>
  
  <p><strong>EDIT2:</strong>
  I figured it out, just reorder view in onWorkflowActivated method:</p>
  
  <pre><code>private void onWorkflowActivated_Invoked(object sender, ExternalDataEventArgs e)
      {
          string colName = workflowProperties.TemplateName;
          SPView defaultView = workflowProperties.List.DefaultView;
          if (defaultView.ViewFields.SchemaXml.Contains(colName))
          {       
              System.Collections.Specialized.StringCollection collStrings = defaultView.ViewFields.ToStringCollection();
              List&lt;string&gt; fields = new List&lt;string&gt;();
              foreach (string field in collStrings)
              {
                  fields.Add(field);
              }
  
              if (fields.IndexOf(colName) != 2)
              {
                  defaultView.ViewFields.MoveFieldTo(colName, 2);
                  defaultView.Update();
              }
          }
      }
  </code></pre>