none
How to select build-in columns for custom view for tasks RRS feed

  • Question

  • Hi,

    I'd ike to create a custom view for tasks - I have a document how it should look like, what columns has to be there and so on. I've thought it would be easy, but it's not. How can I specify which columns are shown?

    I created new view by 

    OL.TableView view = (OL.TableView)olTasksFolder.Views.Add(MY_TASKS_VIEW_NAME, OL.OlViewType.olTableView, OL.OlViewSaveOption.olViewSaveOptionAllFoldersOfType);

    when I try to add some buil-in columns, it tells me that I can not, beacuse it'S already there. If I look for the viewFields property and list all viewFields ViewXMLSchemaNames by

    OL.TableView view1 = (OL.TableView)olTasksFolder.Views[MY_TASKS_VIEW_NAME];
                    var vf1 = view1.ViewFields;
                    StringBuilder sb1 = new StringBuilder();
                    foreach (OL.ViewField f in vf1)
                    {
                        sb1.AppendLine(f.ViewXMLSchemaName);
                    }
                   var result = sb1.ToString();

    I get 12 listed items:

    http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/811c000b
    http://schemas.microsoft.com/mapi/proptag/0x0fff0102
    urn:schemas:httpmail:importance
    urn:schemas:httpmail:hasattachment
    urn:schemas:httpmail:subject
    http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81010003
    http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81050040
    DAV:getlastmodified
    http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/810f0040
    http://schemas.microsoft.com/mapi/proptag/0x0e05001f
    urn:schemas-microsoft-com:office:office#Keywords
    http://schemas.microsoft.com/mapi/proptag/0x10900003

    but only 4 columns are in my view if I look in Outlook? 

    How can I do it. I simply need to programatically select the proper columns, bet way is to use namespaces, because localized names would be a risk in out multiligual environment.

    Thanks

    Filip

    Friday, March 21, 2014 2:47 PM

Answers

  • So this approach worked ("creating the complete view in Outlook manually, then exporting XML by the code and importing it to the new view"). It's the easiest was I guess.

    F.


    Monday, March 31, 2014 9:27 AM

All replies

  • Hello Fillip,

    Did you have a chance to check out the CurrentView property of the Explorer/Folder class? Does it correspond to the fields that are shown on the screenshot?

    What fields are you trying to add?

    Friday, March 21, 2014 3:00 PM
  • Hi, how do you mean it? In Outlook the curretn view is MyView I created. And only 4 columns are shown. If I check it using the code (I get it using OL.TableView view1 = (OL.TableView)olTasksFolder.Views[MY_TASKS_VIEW_NAME];) then it lists all 12 ViewFields

    or?

    Friday, March 21, 2014 3:02 PM
  • but it's not maybe so important - the most important question is:

    how to create new table view and programatically define which columns will shown in this view?

    Friday, March 21, 2014 3:04 PM
  • The fact is that your view may not be used at the moment, even if it exists. Please try to use the CurrentView property and enumerate fields there.

    Friday, March 21, 2014 3:19 PM
  • Filip,

    MSDN provides the following description for the TableView object:

    Outlook provides several built-in TableView objects, and you can also create custom TableView objects. Use the Add method of the Views collection to add a new TableView to a Folder object.

    Use the Filter property to determine which Outlook items to display in the view and the ViewFields  collection to specify the Outlook item properties to display for each Outlook item. Use the GroupByFields to specify the Outlook item properties by which Outlook items are grouped, and the SortFields collection to specify the Outlook item properties by which Outlook items are sorted in the view.

    The definition for each TableView object is stored in Extensible Markup Language (XML) format. Use the XML property to work with the XML definition for the TableView object.

    Use the Apply method to apply any changes made to the TableView object to the current view. Use the Save method to persist any changes made to the TableView object.

    Also you may find the Programmatically Adding a Column to Your Outlook 2007 Inbox Table View article helpful.

    Friday, March 21, 2014 3:23 PM
  • checked

    OL.TableView view1 = (OL.TableView)olTasksFolder.CurrentView;
                    var name = view1.Name;

    name is the same as MY_TASKS_VIEW_NAME. 

    in Outlook 3 fields now, ViewFileds contains 12.

    Friday, March 21, 2014 3:24 PM
  • Thanks Eugene

    I've read it, yes. I can add custom item, that works but it'S not my curretn problem. I canot add built in item into the viewfields, since it's already there. but not visible. Filter is used to filter out the items, or not? The similar is SortFields or OrderByFields. But here is not explained how to define visible fields (columns) and this is what my question is about

    However, I will try the workwround with creating the complete view in Outlook manually, then exporting XML by the code and importing it to the new view. We'll see...


    Friday, March 21, 2014 3:31 PM
  • What value does the XML property return?
    Friday, March 21, 2014 3:32 PM
  • So this approach worked ("creating the complete view in Outlook manually, then exporting XML by the code and importing it to the new view"). It's the easiest was I guess.

    F.


    Monday, March 31, 2014 9:27 AM
  • Good news!

    Thank you for letting us know.

    Monday, March 31, 2014 9:34 AM