Advertisements

Options for Deploying Reusable Workflows in SharePoint 2010

With SharePoint 2010, we have two new workflow types we can create, a Reusable Workflow, and a Site Workflow. Today we’ll concentrate on reusable workflows. And if you’ve been living under a rock for the past few months, let me first explain…

In WSS v3, we could create “reusable” workflows in Visual Studio, and through some third party applications, however, in v3, lots of workflows were generated in SharePoint Designer. And a lot of times, people found out the hard way, that you couldn’t just copy and paste them, or suck them into Visual Studio to re-deploy elsewhere. Those workflows are list-based workflows, which are bound just to a single list, in a single site. You could re-create the workflow on other lists, but, that is time consuming… and not that efficient at all.

There were options however – you could copy the workflow files over to a new list, and edit the workflow files manually, to point to the GUID of the list you wanted to deploy it against, or, use some Visual Studio Voodoo, to write some code to accomplish the same thing. Again, not entirely efficient, and, not out of the box.

With SharePoint 2010 and SharePoint Designer 2010, we finally have some options, out of the box.

image

  1. List Workflow – This is the same list-based workflow you know and love from 2007.
  2. Reusable Workflow – This workflow is tied to a content type, hence why it can be reusable, and the focus of this here article today.
  3. Site Workflow – The site workflow is a different beast altogether, and is a topic for another day. These are, as they sound, bound to sites. Not content types or lists, but, to the site itself. Site workflows are not initiated from list-level actions – they need to either be manually called, or called through code. But I digress – we’ll save this topic for another day…

Now, on to the meat and potatoes of this post. The reusable workflow, and, options for deployment. First, lettuce (you should always have some greens with your meat and potatoes… just ask your mother, she’ll tell you the same thing…) create a simple workflow, that will send an email to a single email address when the workflow is run.

I already have a list called Clients on my site, so we’ll use that. Open SharePoint Designer 2010, and connect up to the site, and click on the Workflows navigation node on the left hand of the screen. When you do, you’ll see the Workflows tab in the ribbon as shown above.

image

 

Create a New Reusable Workflow in SharePoint Designer

Now, you may be able to see the future, and to test this, if you think I am going to say “Click on the Reusable Workflow option in the Workflows ribbon tab”, then you are clairvoyant. Congrats on that! So cool… anyways, click there, just as you knew I was going to say.

image

Go ahead and give it a name, such as Notify Client Engagement Manager, and a description, with whatever you please… then select a content type. Now, something I forgot to mention, is that I had already created a Client content type prior to this, so, you may want to go ahead and do that, in case that’s what you’d like to do, if you’re following along at home. Go ahead – this post will still be here when you get back… I’ll wait.

Ok, done? Now, select your Client content type (as shown below), and click OK. You also may note, that you can associate this reusable content type to ALL content types. While I have not peered beneath the sheets on that one yet (SharePoint 2010 has not even officially launched as of the penning of this article…), I am guessing that it uses the System 0x or Item 0x1 content type to associate to, similar as I did in a previous article on binding custom actions to all list types.

image

Anyhow, back on track again! So, now that we have done. We get our next screen. Do as the man says, and start typing away…

image

A phrase like “email” is helpful – it’ll find the action you are looking for

image

Then press enter, and click on these users in the link that appears

image

And then create your email definition, something like as follows, and click OK.

image

And then click Save back up in the ribbon to save any changes, and when you’re ready, click Publish, that’ll, as you may have thought, publish the workflow.

image

Your workflow has now been created. Now, you’ll need to make sure your list is configured to use it, if, indeed, you’d like to use it. As it works just like the other reusable workflows in SharePoint (Approval, Three-State, etc.), it needs to be configured.

So, check your list, and be sure that it is managing content types,

image

And then, go into Workflow Settings on the list settings page

image

Select the content type…

image

And then configure the workflow…

image

And we’ll see that it is assigned to the content type now

image

Let’s test it, just to make sure… go to New Item > Client from the list page

image

And your workflow should fire. Great! Ok! Now what?

Now Bob, in HR, wants to do the same thing – what can we do? Good thing we created a reusable workflow! We have options, which is the real basis for this article.

Save As Template in SharePoint Designer

In SharePoint Designer 2010, we have the option now to save our Reusable Workflow as a Template. To do so, on the Ribbon UI when you are working with your workflow, select Save as Template.

image

This will automagically save the WSP file of the workflow out to the “Site Assets” library, and it will tell you it did so, as shown below.

image

If you click on the Site Assets link on the left-hand navigation in SharePoint Designer, you will see there should be a new WSP file, corresponding with the name of the workflow you had saved as a template.

image

Next, let’s download the file. Just click on it to save it.

image

 

Packaging and Deploying the Reusable Workflow in Visual Studio 2010

Now, here comes the good stuff. Fire up Visual Studio 2010, and go to File > New > Project from the menu.

image

If you have not seen it before in Visual Studio – under Visual C# > SharePoint > 2010, there is a new project template called Import Reusable Workflow. Select that, give your project a name, etc., and click OK.

image

You will then see the SharePoint Customization Wizard window pop up, select the URL you would like to use for deployment/debugging, and you cannot deploy workflows as sandboxed solutions, so Deploy as a farm solution is your only option. Hit Next >

image 

The next window in the SharePoint Customization Wizard is to specify the project source. Select the WSP package containing your workflow which you had exported earlier.

image

Then, select the items to import – you should only have your workflow listed.

image

Click Finish, and Visual Studio will import your workflow from your solution.

image

And when it’s done, and if it completed successfully, it will tell you so.

image

Now, look at the solution in the Solution Explorer on the right. We are not going to make any changes at the moment, but, if you wanted to, add more code, change the forms, etc., you could do that all here.

image

Right click on the project and select Package

image

Once that is complete, if you look in the project folder (created when you selected the project in Visual Studio), you should see your WSP file for your project.

image

Now, you can deploy this out to the debugging/deployment site you specified in the SharePoint Configuration Wizard portion of the import of the workflow, by right-clicking on the project, and selecting Deploy.

image

Checking the Output window will show you the steps taken for deployment.

image

Now how do you check to make sure it was deployed? Well, in Visual Studio, double-click on Feature1.feature in the solution explorer, and in the Title field of the designer view for the feature, you will see your workflow there with it’s defaulted name of Converted Workflows.

image

In your site collection features, you should see a feature by the same name…

image

Activate it, if necessary, and now your cooking with gas, or really, you can use any other sort of medium for generating intense heat that you desire, I am not going to “hold your feet to the fire” on this. Hah. Sometimes – I just crack myself up.

 

Publishing a Reusable Workflow Globally through SharePoint Designer

The first word in the title of this article is “Options”. So, here is another option – using SharePoint Designer to publish the workflow globally. Now, that sounds bigger than it is, however, you also may note, if you are an astronomy buff, that it did not say “Publish Solarsytemmy”, or “Publish Galaxyally”, or even “Publish Universally”. Maybe because I just made some of those words up? Or, maybe, because you are working within the context of a site collection here – a “world” in SharePoint. I really have no idea – I don’t know who came up with the copy for that specific button, or, rather, any buttons anywhere in SharePoint Designer.

So, start by creating a new workflow, or, you can just use the one we did earlier if you’d like.

image

Give it a step, or else its not much of a workflow…

image

Ok, lets save the workflow…

image

and you’ll see in the Ribbon, that mysterious button Publish Globally. Go ahead – click it.

image

You will then be prompted by SharePoint Designer – telling you the intentions and ramifications, with not even a one word salutation, that publishing this workflow globally will publish it to all sites within the site collection. COOL! Do it!

image

Now, to see this in action, go back into your site, and create a new site.

image

Let’s go with a team site – simple, easy, and comes pre-populated with some lists.

image

Now, lets go into our document library, and check out the workflow settings to see if it is there…

image

Oh, wait – no workflows associated with this list. Let’s add one, to see if we can add ours…

image

And there it is!

image

 

Fun stuff, huh? Yeah, I know many of you who have already started toying with 2010 may have already seen, or even done, some or all of this. The truth of the matter is, I’ve had this sitting in my drafts folder since May 10th, and as you can also see, I am finally getting around to posting it.

Hope this helps – and if not, leave me a comment on where I can provide any clarification 🙂

 

Parachute deployment image borrowed from: http://www.cirruspilots.org/Content/CAPSHistory.aspx

Advertisements

Clippy Jr.

image

Just a short post on the offspring of Clippy – Clippy Jr. You know him well, even if you do not think so. He exists within SharePoint. Don’t believe me? He’s been hiding in plain sight the whole time! Just look at the images taken by a private detective below. I promise, these are not doctored (except for the arrows… those definitely were not in the original images.)

image 

See? There he is! Right in the title bar below the toolbar within this list view!

image

There he is again, on your new list item form!

image

And again, hanging out next to your list items! Always trying to let you know something. However, Clippy Jr. has definitely learned a few things from this mistakes of his father, Clippy Sr.

Ok, now to get onto the meat and potatoes of this post. No, this is not to let you know that there is an attachments for icons, but, a simple little piece of XSL that can be used in your dataview web parts to denote if there are attachments on a list item or not, and then, show Clippy Jr., happily telling you that there is an attachment on the item.

   1: <xsl:if test="@Attachments!='0'">

   2:     <center><img src="/_layouts/images/attach.gif" /></center>

   3: </xsl:if>

And that is all there is to it! @Attachments returns a boolean value that will either be a value of 0, if there are NOT attachments on the list item, or, 1 if there are.

Simple, straight-forward, and extremely handy. Thank you Clippy Jr.!

SharePoint Designer 2007 Error: The folder ‘http://servername’ isn’t accessible. The folder may be located in an unavailable location, protected with a password, or the filename contains a / or \.

Untitled

Wow. What a great error message! Ok, so we get the fact that it is not accessible, since we cannot get to it. This wild goose chase has had me running in circles for a while now. I checked everything. EVERYTHING! Web application policies, permissions, client integration settings, files in the SharePoint root, web.config settings, site definition configurations, group policy settings, and on and on and on… nothing. Every reference I could find of this error either had to do with Forms Based Authentication, and other miscellaneous issues.

Finally, I decided to check the hosts file, located in c:\Windows\system32\drivers\etc\. And there lied the resolution to this issue. Hosts file entries for the server name. When this server was initially being built, in order to get going on a few things, entries were added into the hosts file to masquerade as the future DNS names for the server. However, this was also the cause of the issue. By removing those entries, I could now open the site with SharePoint Designer 2007.

Reason for the post? A glimmer of hope for someone who comes across the same issue in the future.

 

Using a SharePoint Designer Workflow to Build a URL to Populate a Multi-Line Rich Text Field

It’s been quite some time since I have had this exact problem surface for me, so, I had to run through it real quick on a development site to test out the feasibility to do this, and thought I would share…

The requirement that came to me was based on information in one list, build up a URL and some additional text to drop into a multi-line rich text field within another list, using a SharePoint Designer workflow, so no custom code was being installed on the server. The URL we will be re-directing to is a custom page with several data view web parts on it, which bring back information about the selected item.

So, let’s take a look on how to do this…

  1. Create a new workflow in SharePoint Designer, and add a step to it. Add any conditions you need met to the step, and then select the Actions drop-down, and choose More Actions…
    image
  2. From the list of available Workflow Actions, select Build a Dynamic String
    image
  3. Now, click on the Variable: variable text in the step that was just created, and select Create a new variable… from the drop-down menu that appears.
    image
  4. You will see a pop-up window appear, Edit Variable. Fill in the Name and Type fields with the name of the variable, as well as the type. In the case, we’ll be using a String.
    image
  5. Now we click on the dynamic string link (as shown in step 3), and we can start building our HTML link!
    image
  6. Now, where we get to the point when we want to add in a field from the current list item, choose Add Lookup. Select Current Item from the Source drop-down, and select the field, in this case, ID from the Field drop-down. And click OK.
    image

    And then repeat the process for any additional field values from the current item we want to pass through
    image

  7. Now you can see, we have our URL built, and ready to go using variables from the current list item
    image
  8. Next, we’ll add a second step to our workflow, to Update and item, or create, whatever you fancy, in a specific list. For the purposes of demonstrating this functionality, I am just going to update the list item I am working with. You could easily configure this to create a new list item in a different list.
    image
  9. And select the list by clicking on the this list link above, and then, Set this field, in our case, Description To this value,
    image
  10. and when we select the To this value drop-down, select the Workflow Data menu option, and choose the Variable: URL which we created earlier in this process.
    image
  11. And our Update List Item screen should now show the following
    image
  12. Now click OK, and click Finish, and your workflow will be created and published to the server.
    image
  13. Let’s go back to our site, create an item in our, list, and try this out. Select the List Item Menu for the list item you are working with, and select Workflows
    image
  14. Then, we’ll see our workflow that we associated to this list available under the Start a New Workflow section
    image 
  15. Click on our workflow, and we’ll be brought to the workflow initiation form, click on the Start button
    image
  16. Once we do so, our workflow should complete successfully, and we should now have something in our Description field!
    image 
  17. If we hover over the link in the form, we should see it pointing to the URL that we had crafted
    image

    Which should be /foo.aspx?Identifier=1&Title=Workflow Test

And that is all there is to it! Very useful functionality in SharePoint Designer Workflows for building your own dynamic variables, storing them away, and re-using them to achieve the functionality you need.

 

SharePoint Designer 2007 is Now FREE!

I wanted to wait until after April 1st for obvious reasons to blog about about the chatter I was hearing, and sure enough, it was no joke. SharePoint Designer 2007 is now free.

This is both good and bad. Good – because everyone can save on licensing costs, and bad, because it extends a lot of power out to site owners and designers. A lot of damage can be caused to a site by using SharePoint Designer.

Based on that, Robert Bogue [SharePoint MVP], has a great post regarding SharePoint Designer governance, which can be found here: http://www.thorprojects.com/blog/archive/2008/02/12/sharepoint-designer-and-governance.aspx

And with governance in mind, you may want to think about locking down your installation to control the usage of SharePoint Designer. Here is a great post from the SharePoint Designer Team Blog that talks about how to lock down SharePoint Designer within your SharePoint environment: http://blogs.msdn.com/sharepointdesigner/archive/2008/11/25/locking-down-sharepoint-designer.aspx

Updated 4.4.09 – Woody Windischman, who quite literally wrote the book on Microsoft Office SharePoint Designer, put together a great post surrounding the news of this tool now being free. I encourage everyone to read it here: http://woodywindy.spaces.live.com/blog/cns!773832677F575173!633.entry

And finally, the link to download SharePoint Designer 2007, for free: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=baa3ad86-bfc1-4bd4-9812-d9e710d44f42

 

%d bloggers like this: