简体   繁体   中英

Sharepoint 2010 autogenerated workflow column

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.

EDIT: Whole workflow I made in Visual Studio and it is with custom association, initiation an task form.

EDIT2: I figured it out, just reorder view in onWorkflowActivated method:

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<string> fields = new List<string>();
            foreach (string field in collStrings)
            {
                fields.Add(field);
            }

            if (fields.IndexOf(colName) != 2)
            {
                defaultView.ViewFields.MoveFieldTo(colName, 2);
                defaultView.Update();
            }
        }
    }

You can control the logic of how your workflow is associated to the list by creating a custom workflow association page and code behind. You should look into this documentation as a starting point: http://msdn.microsoft.com/en-us/library/ms481192.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM