Ashley
Blog - Robert Bogue [MVP]
Rob's Notebook
SharePoint Calendar

Categories

Links

Archives

Other Blogs

Thor Projects LLC - Welcome : Blog - Robert Bogue [MVP]
Wednesday, September 26, 2007

InfoPath Form Services and Workflow Tasks

InfoPath Forms Services and Workflows in SharePoint can deal a one-two punch to your business problems.  It’s a simple form to create and a framework to take action on those forms.  However, there are a few caveats, however, one of them is that getting a form to open up in InfoPath Forms Services can be setup in the library where the form is stored but when a workflow task is created the link back to the item will try to open up in the InfoPath client (if present) – not in forms services.

Getting the document library to force the InfoPath form to open in InfoPath Forms Services can be done from the document library home page by selecting  Settings-Document Library Settings-Advanced Settings and changing the Browser-enabled Documents to Open browser-enabled documents to “Display as a web page”.

If you want to change the link so that it will open in the browser you’ll have to add a handler to the CreateTask activity.  I’ve added some support routines to break the code up into meaningful chunks. (that you can copy into your project).  The result looks something like:

        private void createTask_MethodInvoking(object sender, EventArgs e)
        {
            string formsServerUrl = GetFormsServerUrl(workflowProperties.Item);
           WorkflowTaskProperties.ExtendedProperties[SPBuiltInFieldId.WorkflowLink] = CreateUrlFieldString("Open form for - " + workflowProperties.Item.File.Name, formsServerUrl);
        }

        public static string CreateUrlFieldString(string name, string url)
        {
            return (string.Format("{0}, {1}", url, name));
        }

        public static string GetFormsServerUrl(SPListItem item)
        {
            return (item.Web.Url + "/_layouts/FormServer.aspx?XmlLocation=" + HttpUtility.UrlEncode(item.Web.ServerRelativeUrl) + "/" + HttpUtility.UrlEncode(item.Url) + "&OpenIn=Browser");
        }

Working from the bottom up, the GetformsServerUrl takes in the item you want the forms server URL for.  It does this by referencing the formserver.aspx and providing the correct parameters.  Above that CreateURLFieldString takes in the URL and a text description to create the string that you have to put into the field.

The actual MethodInvoking event for the createTask activity calls GetFormsServerUrl to get the actual URL and then CreateUrlFieldString to create a meaningful description for the link.  It then uses the SPBuiltInFieldId to get the Guid for the WorkflowLink field.

The net is a link that displays with a customized message and opens in the browser.


Categories: Professional | 6 Comments
 
 
Monday, September 24, 2007

SPFile.Item == null and SPFolder.Item == null

This post requires a bit of explanation.  In SharePoint Folders and Files are really special items – well, most of the time, but I’ll get to that in a moment.  Many of the typical kinds of things that you want to do have to be done with the item object – for instance if you want to manage security.  So I was writing a tool the other day that went through and fixed up security a bit.  (Sort of like the Windows NT+ command line utility CACLS.)

Something happened that didn’t initially make any sense.  When I did an SPFolder.Item I would sometimes get null back as the result.  That’s not suppose to happen – or so I thought.  If I have a folder in a document library it has a corresponding item.  If I have a file in that library it has a corresponding item … most of the time.

The problem comes in when there are files which are necessary for the operation of the list or library which are ghosted (or uncustomized, if you prefer).  You see when a library is created the forms for displaying and item, creating a new item, and editing an item are all provisioned too.  The result is that the document library (or list) has a Forms folder and in that forms folder are created at least those three files.

So when you’re happily traversing down through a structure it’s more than possible that you’re going to encounter SPFolder and SPFile objects that have no corresponding SPListItem.  They don’t have one because they’re not an item in the list.  They’re special files and folders added to support the operation of the list.

Of course, that may not stop you from doing a double take when the SPFolder.Item call returns null.


Categories: Professional | 1 Comment
 
Friday, September 14, 2007

Presentation: SharePoint for Developers

Last night I had the pleasure of speaking in front of the Indianapolis .NET Developers Association (www.indynda.org) again.  It's a great group and I always have a lot of fun.  The topic was SharePoint for Developers.  It's something near and dear to my heart as I work with all sorts of organizations to help them build solutions to leverage SharePoint's power.

If you want to see the slide deck (in PDF format) from the event you can go here.


Categories: Professional | 0 Comments