December 2007 - Posts

SharePoint Designer Workflow issues in SP1

As I was testing out some workflows in a development environment earlier today, that has SP1 applied to it, I was running across some weird issues with some SharePoint Designer workflows.  If I had a SharePoint Designer workflow attached to any list or library that was set to automatically start (either when an item is created or modified) the workflow wasn’t starting at all.  At first I was looking through my logs to see if there was anything showing up because of something in my configuration, and of course nothing was showing up.  The worst part is if I changed the workflow to be able to start manually, the workflow kicks off and completes as expected.

 

After much troubleshooting I found a forum post that suggested if you are logged in as the Farm Admin account workflows that are set to start automatically will not start.  So I created a test user with normal permissions, created a list item with that user, and BAM the workflow works as expected.

 

I have never seen this issue before pre-SP1, so I can only assume is has to do with one of the security enhancements that SP1 included.

 

If you have come across this in a pre-SP1 environment, please let me know… then more testing can continue

 

["Brian"]

Custom Properties on v3 web parts

For the developers that create custom web parts for SharePoint you will come to the time when you want to allow end users to enter extra information to customize the web parts you have created.  Most of the blog posts that I have seen online reference how to create custom properties for v2 (.dwp) web parts, but not v3 (.webpart) web parts.

 

As you know v2 web parts inherit from the Microsoft.SharePoint.WebPartPages.WebPart class and use the following attributes to set properties on the custom categories:

-          Browsable

-          Category

-          WebPartStorage

-          FriendlyName

-          Description

 

Here is an example v2 web part that uses a custom property

 

namespace customWebPart

{

    /// <summary>

    /// Customize a web part

    /// </summary>

    [DefaultProperty("Text"),

     ToolboxData("<{0}:customWebPart runat=server></{0}:customWebPart>"),

     XmlRoot(Namespace="customWebPart")]

    public class CustomWebPart : Microsoft.SharePoint.WebPartPages.WebPart

    {

        private string customProperty = string.Empty;

 

        /// <summary>

        /// Custom Property

        /// </summary>

        [Browsable(true),

         Category("Inetium"),

         WebPartStorage(Storage.Personal),

         FriendlyName("Custom Property"),

         Description("Custom Property Description")]

        public string CustomProperty

        {

            get

            {

                return customProperty;

            }

 

            set

            {

                customProperty = value;

            }

        }

 

        protected override void Render(HtmlTextWriter writer)

        {

            if (CustomProperty == string.Empty)

            {

                writer.WriteLine("No custom property set");

            }

            else

            {

                writer.WriteLine(CustomProperty);

            }

  

            base.Render(writer);

        }

    }

}

 

If you are updating your web parts to the v3 platform which inherits from the System.Web.UI.WebControls.WebParts.WebPart class you will notice that the v2 attributes will not work for your newly created v3 web part.  You will need to adjust your custom property attributes to:

-          WebBrowsasble

-          Category

-          Personalizable

-          WebDisplayName

-          WebDescription

 

Here is an example of a v3 web part that uses a custom property

 

namespace customWebPart

{

    /// <summary>

    /// Customize a web part for redirection

    /// </summary>

    [XmlRoot(Namespace="customWebPart")]

    public class CustomProp : System.Web.UI.WebControls.WebParts.WebPart

    {

        private string customProperty = string.Empty;

 

        /// <summary>

        /// Custom Property

        /// </summary>

        [WebBrowsable(true),

         Category("Inetium"),

         Personalizable(PersonalizationScope.Shared),

         WebDisplayName("Custom Property"),

         WebDescription("Custom Property Description")]

        public string CustomProperty

        {

            get

            {

                return customProperty;

            }

 

            set

            {

                customProperty = value;

            }

        }

 

        protected override void Render(HtmlTextWriter writer)

        {

            if (CustomProperty == string.Empty)

            {

                writer.WriteLine("No custom property set");

            }

            else

            {

                writer.WriteLine(CustomProperty);

            }

  

            base.Render(writer);

        }

    }

}

 

Here is an example of the toolpart that will be displayed when you have a custom property setup

 

Custom Properties toolpart

 

Once you have your custom properties set for your web part, you can then use the information the end users provide to do whatever you need to do.

 

["Brian"]

SPLongOperation - SharePoint Spin Wheel

For those of you that have created applications on the SharePoint platform, you may have some code that takes a while to run in your environment, while the end user is staring at the screen wondering when/if the process is complete.  If only you could create a status page that lets the user know their process is running.  Maybe you want to find out how to utilize the SharePoint “Operation in Progress” spin wheel.  The good news is, there is a class built into the SharePoint object model called SPLongOperation.

 

I have used this class on various occasions when needing to programmatically create sites and modify properties to various object.  In the following example I have a custom Web Part that has a button on it to create a site where I need perform some custom actions.

 

        void _createButton_Click(object sender, EventArgs e)

        {

            using (SPLongOperation operation = new SPLongOperation(this.Page))

            {

                operation.LeadingHTML = "Creating Site";

                operation.TrailingHTML = "Please wait while the project site is being created for " + siteTitle;

                operation.Begin();

 

                SPWeb sub = currentWeb.Webs.Add(siteAbbrev, siteTitle, siteDesc, 1033, "STS#0", false, false);

 

                // Do the rest of my code . . .

               

                operation.End(sub.Url);

            }

        }

 

How the SPLongOperation works is you create a new object of type SPLongOperation then you can change the wording that will be displayed on the screen while the process is running by modifying the LeadingHTML and TrailingHTML properties.  After you have everything ready just kick off the operation using the Begin method.  Once you are in the Begin method, every piece of code you write all happens behind the spin wheel.  And once your code has completed, call the End method and you pass a URL that the user will be re-directed to once your code has completed.  Here is an example page of what it looks like when calling the SPLongOperation class to wrap your code around.

 

SPLongOperation

 

The good thing about using SPLongOperation is it can remove any issues with users being impatient when they think your code has halted, along with giving a consistent look since SharePoint already uses that spin wheel in various places.

SharePoint Training Kit

Microsoft has just recently released the SharePoint Training Kit which contains pre-created end-user training for the SharePoint platform.  This training contains static articles, videos and interactive articles that walk through various aspects of the SharePoint platform.  Along with the good news that Microsoft has created content for all of us to use, they also have created this training kit to be available in two separate editions, Portal and Stand-alone.

 

The Stand-alone version lets end-users install the content directly on their computers and access the information whenever they want be it connected to your network, or out of the office.

 

The Portal edition is a SharePoint solution which you can use to create a Site Collection (or sub-site) that contains this training material published through SharePoint (what a great idea, use SharePoint to teach users how to USE SharePoint). 

 

Using the Portal edition requires some setup, but referencing the installation document you should be able to install it in no time.  You have deploy the solution file, then configure which site collection (which you do through Central Administration) you want the training material to be used on.  When configuring the site collection you will notice you need to create another database, why you ask?  The server edition of the SharePoint Training Kit stores historical information on who completes what course material, so you can actually see who is using the training material and which topics are popular for future.

 

The other plus to this training kit is it is built on top of the SharePoint Learning Kit so you can create your own content and publish it through the same interface.  Here is a sample screenshot of what your MOSS Training site can look like

 

 SharePoint Training Kit

 

Click here to download the SharePoint Training Kit to start teaching your end-users how to use SharePoint.

MySite BreadCrumbs

If you have followed the suggested route of creating a separate web application for your mysites (good idea for managing content databases btw) then you may have come across the issue of not having a breadcrumb link back to your main SharePoint portal.  The good news is you can hook ALL MySites back to your main SharePoint portal by making one change at the MySite host site collection.

 If you go to the Site Settings page directly on your MySite host (i.e. http://mysite.company.com/_layouts/settings.aspx) you can then set the Portal Site Connection for all of your MySites in one place.

 What this solution won't do is place a universal breadcrumb when an individual is on their own MySite (i.e. http://mysite.company.com/personal/JohnDoe) IF that MySite was created before the Portal Site Connection was established. But the good news is, any newly created MySites will have that universal breadcrumb back to your SharePoint portal.