Archive for July, 2007

SPFolder and Content Approval

Posted in Sharepoint Server, Windows Sharepoint Services on July 19th, 2007 by Alonso Robles – 3 Comments

Question:How do I approve a folder in a document library that requires content approval using the SharePoint object model?

Answer:It may seem like a trivial question. After working with the SharePoint object model to create and approve files, it would make sense that any item or folder object would also contain methods needed to check in, publish, and approve them. Well after checking the members of the SPFolder and SPListItem classes on MSDN, I found that they don’t contain properties or methods to intuitively check in, publish, and approve them.

At first, I figured I could use the approve method from SPFile class since the folder object has a property to access the underlying item which has a a property to access the underlying file. Well, it turns out that file property of the item property of the folder object returns a null reference. So, I was back to square one.

As it turns out, the solution to this problem lies in working with the underlying item object. The underlying item object has a property that allows you to access the moderation information object (SPModerationInformation) which contains information about the approval status of the folder. You can then check the status and change as it needed by manipulating the moderation information object directly. Below is a method that I wrote to solve my problem (which was just to approve the folder):

private void ApproveFolder(SPFolder spFolder, SPDocumentLibrary spDocumentLibrary)
{
  if (spFolder.Exists && spDocumentLibrary.EnableModeration)
  {
    SPModerationInformation spModerationInformation = spFolder.Item.ModerationInformation;
    switch (spModerationInformation.Status)
    {
      case SPModerationStatusType.Pending:
        spModerationInformation.Status = SPModerationStatusType.Approved;
        spModerationInformation.Comment = "Got approval?";
        spFolder.Item.Update();
        break;
      default:
        break;
    }
    spModerationInformation = null;
  }
}

Obviously there is a lot more that you can do with the moderation information object. Hopefully, you will find my experience useful.

So You Want to Develop Custom SharePoint Workflows

Posted in Sharepoint Server, Windows Sharepoint Services, Windows Workflow Foundation on July 17th, 2007 by Alonso Robles – Be the first to comment

Elaine Hao, Program Manager of SharePoint Workflow @ Microsoft, put together a really nice series of blog posts on developing MOSS2007 workflows on the Microsoft SharePoint Products and Technologies Team Blog. At the end of the series, she attached a little mini whitepaper that covers everything she covered in her series. I found it extremely useful as I worked on some custom workflow for a client and decided to keep a copy of So You Want to Develop Custom SharePoint Workflows for myself.

189 STSADM Operations

Posted in Sharepoint Server, Windows Sharepoint Services on July 5th, 2007 by Alonso Robles – 2 Comments

Jose Barreto blogged down all 189 STSADM.exe operations with their parameters for Microsoft Office SharePoint Server 2007 in his post, Complete reference of all STSADM operations (with parameters) in MOSS 2007. This is an indispensible reference, especially when you get errors in the Central Admin web interface that you can’t find a way around. As such, I decided to cut-and-paste them for myself. read more »

Creating WSS Solution Packages for Microsoft Office SharePoint Server 2007

Posted in Sharepoint Server, Visual Studio, Windows Sharepoint Services on July 3rd, 2007 by Alonso Robles – 3 Comments

I am assuming you have done custom development for Microsoft Office SharePoint Server 2007. Whether it was a custom web part, workflow, event handler, feature, or module, at some point you probably had to figure out how to deploy it. If you are like me and learn a lot of what you know by doing, then you probably had to fiddle with web.config files and debugging errors with code access security exceptions. This post takes a stroll through a couple of ways to build and bundle a WSP file (a WSS solution package) and deploy it.

Before I begin, you should know that what assumptions I am making about the environment:

A Simple WSP Solution Package

I will update this post with a walk through of creating a simple WSP solution package using the Visual Studio 2005 extensions for Windows SharePoint Services 3.0 in the near future.