Saturday, March 31, 2007

MOSS/WSS : New view style for Lists "Preview Pane"

From the Sharepoint team blog comes this post how to get a preview pane for viewing listitems in a list (which I've never seen before and is actually quite cool!) :

  • Create a new (contacts) list. (This is a good example since this list type has many columns by default.)
  • On the List default view page, click Settings on the toolbar, and then click on Create View.
  • Give the view a name and add all available columns.
  • Scroll down to the Style section. Expand the section and select Preview Pane.
  • Click OK.
  • Hover over the list of items. Notice that as you hover each item, all info related to that item is displayed on the section to the right. The content of the preview pane appears in a similar fashion to the typical item display form. The end results looks similar to the following:
  • This is also not only handy for a contacts list but also for an Issue list, since you can very quickly scan the latest issues.

    Friday, March 30, 2007

    Good ol' 2003

    It may suprise you that I find a couple of things slightly better in the 2003 version of Sharepoint than the 2007 version. One thing is that consistency (and the lack of ;)) of navigation. In SPS2003, you could alert yourself on almost anything (the link was always there!). For example, you could alert yourself on changes of an area. So if a document was added to a document library that was placed on that area you received an alert. Even better was that when a subarea was created, you received an alert that a new area had been discovered!

     

    Now it could be me but I haven't found this 'feature' yet in 2007 (MOSS/WSS), thing that comes close is the searchresult alertme functionality. So if anyone knows where I can find this piece of functionality in 2007 please let me know!

    Wednesday, March 28, 2007

    SPD Workflow activity : Copying a listItem accros a site

    *Update* Download the solution here

    In addition to my previous post I also created a custom workflow activity for Sharepoint Designer where a listitem can be copied accros a site and/or to a list that is not available during the creation of the workflow but will be when the workflow is executed (using workflow variables).

     

    using System;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Collections;
    using System.Diagnostics;
    using System.Drawing;
    using System.Workflow.ComponentModel;
    using System.Workflow.ComponentModel.Design;
    using System.Workflow.ComponentModel.Compiler;
    using System.Workflow.ComponentModel.Serialization;
    using System.Workflow.Runtime;
    using System.Workflow.Activities;
    using System.Workflow.Activities.Rules;
    using Microsoft.SharePoint;
     
    namespace CopyListItemExtended
    {
        public partial class List: SequenceActivity
        {
            private EventLog _eventLog;
     
            public static DependencyProperty ListItemIDProperty = 
    DependencyProperty.Register("ListItemID", typeof(string), typeof(List));
            public static DependencyProperty SrcUrlProperty = 
    DependencyProperty.Register("SrcUrl", typeof(string), typeof(List));
            public static DependencyProperty DstUrlProperty = 
    DependencyProperty.Register("DstUrl", typeof(string), typeof(List));
            public static DependencyProperty SrcListNameProperty = 
    DependencyProperty.Register("SrcListName", typeof(string), typeof(List));
            public static DependencyProperty DestListNameProperty = 
    DependencyProperty.Register("DestListName", typeof(string), typeof(List));
     
     
            [ValidationOption(ValidationOption.Required)]
            public string SrcUrl
            {
                get
                {
                    return (string)base.GetValue(SrcUrlProperty);
                }
                set
                {
                    base.SetValue(SrcUrlProperty, value);
                }
            }
     
            [ValidationOption(ValidationOption.Required)]
            public string DstUrl
            {
                get
                {
                    return (string)base.GetValue(DstUrlProperty);
                }
                set
                {
                    base.SetValue(DstUrlProperty, value);
                }
            }
     
            [ValidationOption(ValidationOption.Required)]
            public string SrcListName
            {
                get
                {
                    return (string)base.GetValue(SrcListNameProperty);
                }
                set
                {
                    base.SetValue(SrcListNameProperty, value);
                }
            }
     
            [ValidationOption(ValidationOption.Required)]
            public string DestListName
            {
                get
                {
                    return (string)base.GetValue(DestListNameProperty);
                }
                set
                {
                    base.SetValue(DestListNameProperty, value);
                }
            }
     
            [ValidationOption(ValidationOption.Required)]
            public string ListItemID
            {
                get
                {
                    return (string)base.GetValue(ListItemIDProperty);
                }
                set
                {
                    base.SetValue(ListItemIDProperty, value);
                }
            }
     
            protected override ActivityExecutionStatus 
    Execute(ActivityExecutionContext executionContext)
            {
                //Set up the Event Logging object 
                _eventLog = new EventLog("Workflow");
                _eventLog.Source = "SharePoint Workflow";
     
                try
                {
                    //Send the email 
                    Copy();
                }
                finally
                {
                    //Dispose of the Event Logging object 
                    _eventLog.Dispose();
                }
     
                //Indicate the activity has closed 
                return ActivityExecutionStatus.Closed;
            }
     
     
            private void Copy()
            {
                SPSite srcSite = new SPSite(SrcUrl);
                SPWeb srcWeb = srcSite.OpenWeb();
     
                SPSite dstsite = new SPSite(DstUrl);
                SPWeb dstweb = dstsite.OpenWeb();
     
     
                string error = string.Empty;
     
                try
                {
                    SPList destList = dstweb.Lists[DestListName];
                    SPListItem item = srcWeb.Lists[SrcListName].GetItemById(Convert.ToInt32(ListItemID));
                    item.CopyTo(dstweb.Url.ToString() + "/" + destList.Title.ToString() + 
    "/" + item.File.Name.ToString());
                    _eventLog.WriteEntry("Worklow succes: Item : " + item.Title.ToString() 
    + " has been succesfully copied from : " + srcWeb.Lists[SrcListName].Title.ToString()
    + " to : " + destList.Title.ToString());
     
                }
                catch (System.Exception Ex)
                {
                    //Log exceptions in the Event Log 
                    _eventLog.WriteEntry("Workflow Error :" + Ex.Message.ToString() 
    + error.ToString(), EventLogEntryType.Information);
                }
     
                finally 
                {
                    srcWeb.Close();
                    srcWeb.Dispose();
                    srcSite.Close();
                    srcSite.Dispose();
     
                    dstweb.Close();
                    dstweb.Dispose();
                    dstsite.Close();
                    dstsite.Dispose();
                }
            } 
     
     
            public List()
            {
                InitializeComponent();
            }
     
     
        }
    }


    And the including XML chunk that needs to be added in WSS.ACTIONS:

    <Action Name="Copy List Item Extended"

    ClassName="CopyListItemExtended.List"
    Assembly="CopyListItemExtended, Version=1.0.0.0, Culture=neutral, PublicKeyToken=54d1a6fdf526a294"
    AppliesTo="all"
    Category="Sample">
      <RuleDesigner Sentence="Copy List %1 from this %2 to this %3 and from this %4 to this %5.">
        <FieldBind Field="ListItemID" Text="ItemID" DesignerType="TextArea" Id="1"/>
        <FieldBind Field="SrcUrl" Text="Source Site" DesignerType="TextArea" Id="2"/>
        <FieldBind Field="DstUrl" Text="Destination Site" DesignerType="TextArea" Id="3"/>
        <FieldBind Field="SrcListName" Text="Source List" DesignerType="TextArea" Id="4" />
        <FieldBind Field="DestListName" Text="Destination List" DesignerType="TextArea" Id="5" />
      </RuleDesigner>
      <Parameters>
        <Parameter Name="ListItemID" Type="System.String, mscorlib" Direction="In" />
        <Parameter Name="SrcUrl" Type="System.String, mscorlib" Direction="In" />
        <Parameter Name="DstUrl" Type="System.String, mscorlib" Direction="In" />
        <Parameter Name="SrcListName" Type="System.String, mscorlib" Direction="In" />
        <Parameter Name="DestListName" Type="System.String, mscorlib" Direction="In" />
      </Parameters>
    </Action>

    SPD Workflow activity : Creating a document library

    Using the codesample of Todd Baginski's post of creating a custom activity to email, I modified the code to create a doclib using two variables that an user enters in SPD. These two variables are the url of the site and the title of the document library.

    I replaced the code of Todd with this chunk :

    using System;

    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Collections;
    using System.Diagnostics;
    using System.Drawing;
    using System.Workflow.ComponentModel;
    using System.Workflow.ComponentModel.Design;
    using System.Workflow.ComponentModel.Compiler;
    using System.Workflow.ComponentModel.Serialization;
    using System.Workflow.Runtime;
    using System.Workflow.Activities;
    using System.Workflow.Activities.Rules;
    using Microsoft.SharePoint;
     
    namespace CreateDocumentLibrary
    {
        public partial class Doclib: SequenceActivity
        {
     
            private EventLog _eventLog; 
     
            public static DependencyProperty UrlProperty = 
    DependencyProperty.Register("Url", typeof(string), typeof(Doclib));
            public static DependencyProperty ListNameProperty = 
    DependencyProperty.Register("ListName", typeof(string), typeof(Doclib));
     
     
            [ValidationOption(ValidationOption.Required)]
            public string Url
            {
                get
                {
                    return (string)base.GetValue(UrlProperty);
                }
                set
                {
                    base.SetValue(UrlProperty, value);
                }
            }
     
            [ValidationOption(ValidationOption.Required)]
            public string ListName
            {
                get
                {
                    return (string)base.GetValue(ListNameProperty);
                }
                set
                {
                    base.SetValue(ListNameProperty, value);
                }
            }
     
            protected override ActivityExecutionStatus 
    Execute(ActivityExecutionContext executionContext)
            {
                //Set up the Event Logging object 
                _eventLog = new EventLog("Workflow");
                _eventLog.Source = "SharePoint Workflow";
     
                try
                {
                    //Send the email 
                    CreateList();
                }
                finally
                {
                    //Dispose of the Event Logging object 
                    _eventLog.Dispose();
                }
     
                //Indicate the activity has closed 
                return ActivityExecutionStatus.Closed;
            }
     
            private void CreateList()
            {
                try
                {
                SPSite site = new SPSite(Url);
                SPWeb rootweb = site.OpenWeb();
                SPListCollection lists = rootweb.Lists;
     
     
                SPListTemplateType listTemplateType = new SPListTemplateType();
                listTemplateType = SPListTemplateType.DocumentLibrary;
                lists.Add(ListName, "", listTemplateType);
             _eventLog.WriteEntry("Worklow succes: List 
    created at: "
    + rootweb.Title.ToString());
                }
                catch (System.Exception Ex)
                {
                    //Log exceptions in the Event Log 
                    _eventLog.WriteEntry("Workflow Error :" + 
    Ex.Message.ToString(), EventLogEntryType.Information);
                }
            } 
     
            public Doclib()
            {
                InitializeComponent();
            }
        }
    }
     

    And the XML to publish this code in SPD in the WSS.ACTIONS looks like:

     

    <Action Name="Create Document Library"
    ClassName="CreateDocumentLibrary.Doclib"
    Assembly="CreateDocumentLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=54d1a6fdf526a294"
    AppliesTo="all"
    Category="Sample">
    <RuleDesigner Sentence="Create document library %1 on %2.">
    <FieldBind Field="Url" Text="Link to site" DesignerType="TextArea" Id="1"/>
    <FieldBind Field="ListName" Text="Name of the doclib" Id="2" DesignerType="TextArea"/>
    </RuleDesigner>
    <Parameters>
    <Parameter Name="Url" Type="System.String, mscorlib" Direction="In" />
    <Parameter Name="ListName" Type="System.String, mscorlib" Direction="In" />
    </Parameters>
    </Action>

    </Actions>

    So if you want use this code, follow all the steps that are described in the post of Todd and replace his code and xml with mine and you could be a happy man! ;)

    Monday, March 26, 2007

    Commercial: VW Touareg

    This has nothing to-do with Sharepoint or any other IT related subjects but I just find this Volkswagen Touareg commercial so absolutely brilliant I wanted it to share it with you ;) 

    The casting is superb! And erm.. it kinda feels like promoting my own pieces of code ;)