Thursday, 20 November 2014

How to create a reusable workflow in SharePoint Designer (SharePoint 2010)


  • Synopsis

    This guide will show you how to create a reusable workflow in SharePoint Designer.
  • Applicable to

    All PlexHosted SharePoint 2010 accounts.
  • Prerequisite

    • a PlexHosted SharePoint 2010 account
    • a PlexHosted SharePoint 2010 sit
    • SharePoint Designer
  • Introduction: SharePoint 2010 gives you an ability to create a reusable workflow and associate it to a content type. Then you can easily associate this workflow to a library or list that uses this content type. What is more, you can make this workflow globally reusable and you will be able to use this workflow at any site or sub site within your site collection.

  • How to

  1. First of all you need to create a new content type for reusable workflow (you can associate a reusable workflow to the existing content type as well). Create a content type like shown at the screen below (note that we`ve created a new Experience Level column of Choice type with values – blank, Beginner, Intermediate and Specialist and added it to this new content type):
  2. The next step is to create a list that uses this newly created content type. Let`s create the Employee Experience list and add the Experience Level Content type as default to this list.
    • Create new list.
    • Click on List settings – Advanced settings.
    • Under the Allow management of content types? choose Yes and click OK.
    • Return to List Settings page and click on Add from existing site content types hyperlink.
    • Add the Experience Level Content type to the list.
    • Click on Change new button order and default content type hyperlink and set this content type as default for the Employee Experience list.
    • Modify the view of the list so that it contains all required fields.
  3. Now open your SharePoint site in the SharePoint Designer.
  4. Click on Reusable Workflow button to create new workflow.
  5. Enter the name and description of new workflow, choose your newly created content type in the Content type field and click OK.
  6. Define the steps of your new workflow. In our example, we created a simple workflow which will set the employee experience level according to the years of experience of employee.
  7. Click on Publish.
  8. Then click on Workflow Settings.
  9. At the Workflow Settings click on Associate to List. You will see all the lists that use Experience Level Content type in the drop-down menu. Choose the newly created Employee Experience list.
  10. A new Add a workflow tab should open in your browser. Choose Experience Level Content type in the Content type section. Select the Experience RW reusable workflow template in the Workflow section. Give a unique name for this workflow.
  11. Choose the start options for your workflow and click OK.
  12. You will see that the Experience reusable workflow has been created.
  13. To check how this workflow works add the new item to the Employee Experience list. Click on Add new item or click at the New Item drop-down menu in Items tab and choose Experience Level Content type.
  14. Fill in the form with the necessary data. You can leave the experience level field blank or choose the incorrect value in it in order to check how the workflow will update this field.
  15. Refresh the page and you will see that the status of our workflow is Completed and the Experience level is set to Beginner.
  16. If you need further assistance, please do not hesitate to contact the PlexHosted support staff.

Reference:

http://plexhosted.com/billing/knowledgebase/255/How-to-create-a-reusable-workflow-in-SharePoint-Designer-SharePoint-2010.html

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 0×1 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 :)

Reference:

http://sharepointyankee.com/2010/12/11/options-for-deploying-reusable-workflows-in-sharepoint-2010/

SharePoint 2010 Workflow Interview Questions


These are the basic level questions which can be asked in a interview. I will write a separate Post for high-level workflow interview questions.
Q. What is a workflow?
Ans. Workflows are the way an organization functions, a series of actions that correspond to a work process, such as the process for purchase orders.SharePoint 2010 helps you automate these workflows, thereby increasing the efficiency and productivity of the organization.
Q. What are the types of workflow that you can design in SharePoint 2010.
Ans. you can design List Workflows, Reusable List Workflows and Site workflows using SharePoint designer 2010.
Q. What Reusable List Workflows and Site workflows ?
Ans.
Reusable List Workflows -
You can create a reusable list workflow (reusable workflow) in the top-level site in the site collection, and that workflow can be made globally reusable — meaning that the workflow can be associated to any list, library, or content type in the site collection. You can also create a reusable workflow in any subsite in the site collection; this workflow is available for reuse in that particular subsite.
Site workflows - A site workflow is associated to a site — not to a list, library, or content type. So unlike most workflows, a site workflow is not running on a specific list item. Because of this, many of the actions that are available for items not available for site workflows.
Q. Can you modify the Out-of-Box workflows in SharePoint 2010 ?
Ans. In SharePoint 2010, you have an option to customize the Out-of-Box workflows. The four most popular workflows in SharePoint Server 2007 — the Approval, Collect Feedback, Collect Signatures, Publishing Approval workflows — have been completely rebuilt as declarative reusable workflows, meaning that they are now fully customizable in SharePoint Designer 2010.
Q. What are events, actions, conditions and steps?
Ans. Lets look at this one by one.
Events - An event is what starts or initiates a workflow. Events can also be used to manage the timing of actions within a workflow, such as waiting for the status of an item to change. There are three events that can start a workflow:
* An item is created.
* An item is changed.
* A workflow participant clicks a start button on the SharePoint site.

Actions –
An action is the most basic unit of work in a workflow. SharePoint Designer 2010 provides a set of ready-made, reusable actions for you to incorporate into your workflow.
For example, your workflow can:
* Create, copy, change, or delete list items (including documents).
* Check items in or out.
* Send an e-mail message.
Conditions - When you design a workflow, you can use the workflow editor to create rules that apply conditional logic to SharePoint sites, lists, items and content types. A rule establishes a condition where the workflow performs the associated action only if that condition is true. For example, you can create a rule where the workflow sends a reviewer an e-mail message only if an item is created by a specific person.
Q. What are Parallel and Serial actions ?
Ans. When you have more than one action associated with a condition, the actions can be set up to run at the same time (parallel) or one after another (serial), the default.
Q. What are the Types of forms associated with the workflow ?
Ans. With SharePoint Designer 2010, you can create three types of workflow forms:
Initiation form – An initiation form gathers information from the workflow participant when they start the workflow. It is automatically generated when you create the workflow in SharePoint Designer 2010. Initiation forms are displayed to users when they manually start a workflow on a given SharePoint item. With an initiation form, users can specify additional parameters or information about the workflow as it applies to the given SharePoint item.

Task form –
A custom task form allows workflow participants to interact with tasks in the Tasks list specified for the workflow. With the Custom Task Wizard, you can easily create custom form fields and add them to a custom task form. When you finish designing the workflow, SharePoint Designer 2010 automatically generates the InfoPath or ASP.NET forms for your custom tasks.
Reusable workflow – association form – A reusable workflow, by default, only provides the fields common to all items, such as Created and Modified by. This is because a reusable workflow isn’t by default associated with a list, library, or content type. An association form enables you to associate fields with a reusable workflow so that the fields will be available when you design and run the workflow.
Q. When are these forms get created ? And how do you customize it ?
Ans. SharePoint Designer 2010 automatically generates the forms, but you can customize them by going to the settings page for the workflow, in the Forms section, click the form you want to customize. Workflow forms are either InfoPath or ASP.NET pages. They are stored on the SharePoint site with the workflow source files.

Reference:

http://www.learningsharepoint.com/2010/07/26/sharepoint-2010-workflow-interview-questions/