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

Working with Web Parts in SharePoint Designer 2010

Another tidbit I wanted to share regarding SharePoint Designer 2010 that may be of interest to a lot of developers, site administrators, designers, and power users alike. If you have the permissions, you now have options directly in the interface of SharePoint Designer, to save your web parts out to a local file, or, push it into the Site Gallery!

In SharePoint Designer, let’s add a Data View Web Part to our page, by going to the Insert ribbon tab, selecting Data View, and choosing the list which we want to create an XSLT Data View for…

image

Then configure your web part as you’d like to… and from there in SharePoint Designer 2007, we were stuck with going back to the page which we placed this, using the chevron on the web part in Edit mode on the page, and then choosing Export from the menu. This is no longer with SharePoint Designer 2010!

If you look at the ribbon while you are working on the Data View Web Part, click into the Web Part ribbon tab under List View Tools

image

Once you have done that, if you look all the way over to the right of that ribbon tab, you will see a section called Save Web Part.

image

Which presents two options, To Site Gallery, and To File. This is just another one of the many timesavers built into the overhauled SharePoint Designer 2010. If we select To Site Gallery, we are presented with a pop-up that will allow you to set the title and description for your web part

image

As well as a Set Properties… button, which will allow you to set web part properties on the saved version of the web part before putting it into the gallery.

image

Once you click OK, you are presented with another pop-up

image

This asks you if you want to always just show data from the current site list, tied to the List ID GUID, or, if you want to make it relative, which will tie it down to the list name itself, relative to the site in which it is displayed.

Now, if we meander on over to the web part gallery for this site collection, Site Actions > Site Settings

image

and selecting Web Parts under Galleries

image

We will now see that our web part which we created in SPD 2010, is now deployed out to the Site Collection Web Part Gallery!

image

If we choose the alternate option, To File from the Save Web Part section of the ribbon, you will be prompted to save it locally as expected.

image

There is a lot of new functionality in SharePoint Designer 2010. As I get around to it, I’ll keep more of these posts coming.

 

Adding Custom Actions to the Ribbon UI in SharePoint 2010 Using SharePoint Designer 2010

image In my last article, Adding Custom Actions to the List Item Menu in SharePoint 2010 Using SharePoint Designer 2010, We walked through the process of adding custom actions to the List Item Menu using SharePoint Designer 2010, today, we’re going to have a look at the other Custom Action functionality available to us in SharePoint Designer 2010.

This article is going to group the rest of the options within our Custom Actions drop-down in SharePoint Designer 2010 together, as they are all basically doing the same thing, adding an item to the Ribbon UI, just for different forms (View, Edit, New, and Display).

imageFirst, let’s open SharePoint Designer 2010 back up. So, let’s go into our 2010 test site, and click on the Edit Site in SharePoint Designer action off of the Site Actions menu.

 

 

 

 

 

 

 

 

 

 

 

 

 

image

Now that we have SharePoint Designer open, click on Lists and Libraries, under the Navigation > Site Objects, area on the left-hand side of your window.

 

 

 

 

 

 

Here is a quick little tip while we are here as well, that is new in SharePoint Designer 2010. If you hover your cursor over Lists and Libraries, as well as any of the other Site Objects navigation options, you will see a thumbtack appear on the right.

image 

image

If you click on this, it will expand your Lists and Libraries, or any of the other options, below the Site Objects on the left-hand side, allowing you 2007-like left-side navigation navigation between your objects.

Now, on with the show… as I mentioned back towards the start of this article, we’re going to look at the remaining Custom Actions we can build into our lists from SharePoint Designer 2010.

Click on any list that you have on the site. In this example, we will be using a tasks list that I had created for demonstration purposes.

 

 

 

 

 

 

 

 

imageNow that we have our Tasks list loaded, we do not want to use the Custom Actions window in the lower-right hand side of our screen. This will automatically create a Custom Action for the List Item Menu if we click on the New… button. No, to create other types of Custom Actions, we need to use the Custom Action menu in the Ribbon UI to do what we are looking to do.

You will however notice, that by clicking here, the Ribbon context at the top of the screen changes from the List Settings ribbon, to the Custom Actions ribbon.

image 

We are going to use the Custom Actions ribbon to create our first of four custom actions for this article. First, we are going to start with the Display Form Ribbon. To start creating one of these, click on the Custom Action button in the ribbon, and select Display Form Ribbon

image

By doing so, we see the familiar Create Custom Action window pop-up that we saw in my last article on the subject.

image

For our example, lets fill in a Name, Description, and under the Select Type of Action, we are going to choose Initiate workflow. For this, I just created a simple list-level workflow, which will e-mail the owner of the task, CC’ing the current user, to request them to review and update the task, with a link back to the task (see screenshot below).

image

Select our workflow from the drop-down next, in this example, our workflow name is Task Review Request.

image

Next, if we scroll down in our window, we are going to specify a 32×32 image, so that we have a fancy little icon to go with our button. We could sue a 16×16, but, that will be quite small, and since we’re on the ribbon, we want this to stick out a bit. So, I browsed in the layouts folder in the SharePoint root to find an e-mail related icon, and did, at /_layouts/images/centraladmin_systemsettings_email_32x32.png. You could also use the Browse button to find a local image on your computer or network file share to use.

image

You will also see in the advanced section, that the wizard automatically entered in the Ribbon Location. This location, Ribbon.ListForm.Display.Manage.Controls._children, is great, because, really, were you going to remember that? Here is a listing of what each of these options are:

Form Name Ribbon Location
Display Form Ribbon.ListForm.Display.Manage.Controls._children
Edit Form Ribbon.ListForm.Edit.Actions.Controls._children
New Form Ribbon.ListForm.Edit.Actions.Controls._children
View Form Ribbon.ListItem.Actions.Controls._children

 

I have also created a blog post, just with this information, available here, which I will reference in later articles, as needed: SharePoint 2010 Custom Actions – Default Form Ribbon Locations

Now, below there, there is the options for Rights mask. This allows you to assign permissions of who can actually see this custom action. If the user does not meet the requirements, which are comma separated values from the SPBasePermissions class enumeration, they do not see the custom action. We will not apply any currently to this item, leaving it for all to see. But, the option is there.

You can choose your own sequence number for this as well. Generally, the best practice is to use anything over 10,000.

Now, once we are set with this, lets click on OK on the Custom Action Wizard, and now lets see this in action! Let’s go back to our list in SharePoint… Let’s use the List Item Menu, and select View Item

image

We will get a modal dialog window now with the Display Form, that we linked our Custom Action to. As you will see, we now have a new icon in our View Ribbon, which shows our fancy little e-mail icon, as well as the title of the Custom Action:

image

Clicking on this will then initiate the workflow which we associated with the Custom Action

image

And once we click Start on the workflow initiation form, the workflow will then start! Very cool stuff.

image

To be sure it is actually doing its thing, let’s check the workflows for that list item, back from the main list page, by selecting the Workflows option from the List Item Menu.

image

Once the page loads, you will see we have a completed workflow for our Task Review Request workflow that we created

image

Now, to finish up this article, we’re going to add the same Custom Action to the other forms on this site as well. So, back in SharePoint Designer 2010, opened to our list, lets create a new Custom Action for each of the other three forms, and see where they show up.

The only change we are going to make however, for each one, is just in the title. We could have it named the same thing for each form, sure, but, I want to show you where these end up in the SharePoint UI, and to do so, I am doing to insert the name of the form into our Custom Action title.

As you can see, when we choose a different ribbon location for our Custom Action, we get a new Ribbon Location automatically populated for us:

image

Follow the previous steps in the article if you need to to create these additional actions. When finished, we should have four Custom Actions in total assigned to our list, one for each of the form types:

image

Now, let’s head back to our our SharePoint site and see where these now appear in the UI.

First – let’s have a look at the List View form ribbon – click on the Items tab under the List Tools ribbon image , and you will see a section for Actions. You will also see in here, that our ViewForm Custom Action is available here. What does this allow us to do? Well, using the multiple-item selection functionality in SharePoint 2010, we can run our action against multiple list items!

image

Well, you would think… but if you attempt to do so, you will get an error, so, only do this on a per-item basis. The functionality is not smart enough to fire up three consecutive workflows by using SharePoint Designer 2010 for each of the items you have selected. It will work fine when going through them one by one.

Next, if we go into the Edit Item view form for one of our tasks

image

We will see that we have our Custom Action appearing in the Actions area of the form

image

And the same goes for when we go to create a new Task

image

However, until the task is created, you will not be able to run the workflow, as until you hit Save on the new item form, your task does not exist as of yet, so, the workflow has nothing to bind to, just something to keep in mind when creating your Custom Actions in SharePoint Designer 2010. If you do try and run your workflow from your Custom Action – you will get the lovely Runtime Error.

image

I just wanted to show you where this would appear, and that even though the Edit and New Forms use the same Ribbon Location (Ribbon.ListForm.Edit.Actions.Controls._children), they are actually bound to the individual forms themselves.

I hope this article was informative, and helps shed some light on some of the new functionality available in SharePoint 2010, and SharePoint Designer 2010. Please let me know what you think, or leave any questions regarding this material in the comments, and I will answer them as soon as I can.

 

Property Bag Access in SharePoint Designer 2010

Almost daily, I am discovering new things with SharePoint 2010. Today, I was working away on my presentation for SharePoint Saturday NYC coming up in a few days, putting on the finishing touches, and, I came across this gem in SharePoint Designer 2010.

When you have a site open in SharePoint Designer 2010, in the ribbon, all the way over to the right, you’ll see a button for Site Options

image

Click it, go ahead, it’s not going to bite.

Now, the first tab you are opened to in this new window is labeled Parameters. What it should be labeled as however, is Property Bag. as that is exactly what it is.

image

Once just a bucket for developers to play with, the property bag is now exposed in SharePoint Designer 2010. Which is awesome. Now, properties which you were storing there for your own use, can be extended out to Site Administrators, and Power Users to make use of! Awesome, yes. Also, dangerous. If you have applications which rely on the Property Bag, you have now been warned. Others can access, change, view, and delete the data within the property bag.

And now back to your regularly scheduled programming…

 

Installing SharePoint Designer 2010 Beta

SharePoint Designer is an invaluable tool for site administrators and developers within SharePoint. After the Microsoft SharePoint Conference in Las Vegas, and seeing all of the great things that Microsoft has done to improve this tool from its humble beginnings back when it was FrontPage. So, naturally that I now have full-on access to the 2010 Beta, I am anxious to start playing around with SharePoint Designer 2010 first hand.

The first step in this process of course, is to get it installed. To do so, I am starting from the first site I have created in my new environment.

Going to the Site Actions menu (it’s moved by the way, over to the left side of the page from 2007), I select Edit Site in SharePoint Designer

image

Since I do not already have Designer 2010 installed, a dialog window pops up, basically letting me know that I do not have it installed, and I can do so. Just like SharePoint Designer 2007, SharePoint Designer 2010 will be free for all users. And since the Beta is all that is around now, that’s what it will install for me.

image

I select the language I am looking to install SharePoint Designer in (English, German, Spanish, Japanese, French, Russian, and Chinese are other available languages that can be selected, in addition to English, as shown above), and choose my platform. Even though SharePoint 2010 is only 64-bit, SharePoint Designer 2010 is available in both 32 and 64 bit, as it is intended to be run from the desktop, and many of us still run 32 bit desktops, as we probably will for a long time to come.

Once done, selecting the Download button goes out and fetches the right download, and prompts me to run and/or save it.

image

It’s sizeable for my options as chosen (English 64-bit) at 277MB, happy that I have a nice and fast connection.

Once it’s up and running, the installer will extract the files, and then move on.

image

You have the usual EULA, agree and continue

image

Once accepted, you really cannot miss what is needed on the next screen. Microsoft made sure of that.

image

However, you can customize your installation by clicking on the Customize button, setting a new installation directory, setting your user information, and adding or removing features from the install. With the default installation, its a fairly hefty installation at 1.03G, but, I have a feeling it will be well worth it…

image

The installation begins (of course after you have clicked the Install Now button.

image

And that’s it. You’re done!

image

 

%d bloggers like this: