Writting a basic Workflow in SharePoint Server 2007

Maybe is a good time to start a new phase on my blogging experience. My friend Luis Du Solier MVP in SharePoint has a blog in English as well, so I think from now on I will write and share some information in English language. The reason is just for fun and just for share content about Microsoft technology with the entire world.  I need to learn how to express myself in new ways and I think blogging it’s a great opportunity to do that.


 


Ok, let’s talk about the workflow capabilities of Microsoft Office SharePoint Server 2007.


 


First, let me tell you that a workflow it’s a concept for describing a set of steps and conditions that a certain process can have for ensure the accomplishment of several rules that are enforce in any aspect of a business.


 


In Microsoft Office SharePoint Server 2007 a.k.a MOSS 2007 we can enable workflow scenarios for automate a business process. In this post I will create a very basic workflow and share how can you use the Microsoft Office SharePoint Designer 2007 to create a custom workflow.


As a developer you write workflows in your apps. If you take the time to see your code, you will find from an overall perspective a workflow existing in your application that represents the business rules that you need to enforce in order to stream line a business process. Microsoft in the new version of the .NET Framework called .NET Framework 3.0, has integrated a full workflow engine that developer can use to understand and represent business process or program flow. MOSS 2007 uses Workflow Foundation from the Microsoft .NET Framework 3.0 to enable rich and extensible Workflow scenarios applied to the collaboration space.


 


Let’s see.


Crescencio Estrada owner of Mexican Curios Shop needs to be aware of some of the most expensive artisanal items that he sells and also buy from local artisans. He has several people doing this job, but, for really expensive items he needs to approve the purchase. To do so, he wants to see some relevant information about the item and most important, the cost and base on that he approve or deny the purchase.

curius01.jpg


As you can see, we have too special items in the Document Library and also we have a cost column. This document library has enable the content approval feature. We will use SharePoint Designer 2007 Beta to enable a very basic workflow that has the following condition:




  • If the Cost is less than $1, 000 then they are approve


  • If the Cost is greater than $1, 000 then needs to be approve



  1. Open the Microsoft Office SharePoint Designer 2007 Beta


  2. Select File – Open Web Site and type the Web Site Url.  

curius02.jpg


Now SharePoint Designer loads the site structure.




  1. Select File – New


  2. Select the SharePoint Content Tab and select Workflow from the category list


  3. Select the Blank Workflow Template and click Ok 

curius03.jpg


SharePoint Designer 2007 will load a new windows called Workflow Designer.


curius05.jpg


In the Workflow Designer we can give a name for our workflow and select on which component of our site we want to enable this custom workflow. And also, we can define some of the start options for our workflow.


curius06.jpg


There are some useful command button we can use to enable variables and initialization parameters for our workflow. But we only are going to click Next.


Now we will design the steps of our workflow, we have two options Condition and Actions.


When we click the Condition button several options are displayed:


curius07.jpg


This condition can help us to evaluate any value or state of each document that is in Special Items document library. We will select Custom Condition (Special Items).


curius08.jpg


In the field link we are going to select the Cost field that we have in the Special Items Document Library.


curius09.jpg


Then select the equals link to chose the condition. 


curius10.jpg


Now type the value we define for this condition.


curius11.jpg


Ok, now we have a condition configured and it’s time to set the action that will fire when this condition it’s true.  There are some available actions when a condition occurs.


curius12.jpg


In this case we will define a Set Moderation Status action allowing us to select the approve, pending or denied status for our document base on the condition previously evaluated. Because the cost of our Special Item is less than 1000 we will select Approved and define some comment.


curius13.jpg
curius14.jpg
There is a link called Add “Else If” Condition Branch so we can still evaluate other values. So click this link to create another branch. And select the same condition (Custom Condition) but whit the Is greater than condition criteria.
We also can define more actions for the same condition. In this case I will send a email to Mr. Crescencio Estrada.curius15.jpg
Then, just click the Finish button. And the Workflow designer will compile and save this workflow.


Image 17


Upload some document to our Special Items Document Library don’t forget to specify a cost lower than 1000 a greater than 1000. You will see that the status column is Pending or Approved base on the condition.


Image 18


Well, in this basic post we see how can define a custom workflow for a Document Library in MOSS 2007.

17 thoughts on “Writting a basic Workflow in SharePoint Server 2007

  1. When i try to add a new workflow as mentioned, I get error message as “Failed to load the workflow”. If anyone can help me in this regrad, it will be highly appreciable.

  2. This may sounds stupid. Is there a way to create a work flow to that can crete new folders,in stead of files, in a document library?

  3. Hi,

    Is there a way to move the document to another document library after it has been approved?

    Thanks in advance.

    Heine

  4. You can create a new workflow in SharePoint Designer. First, configure that this workflow to fire up when an item has been updated. Second, add a new condition when the “workflow status” field has been approve then one action to copy the document to another document library and use another action to remove the document from the current document library.

    Make sense?

  5. when i click on action i am not getting set moderation status action. please tell me whats wrong and how i get this.

  6. I am trying to use Workflows Sharepoint Server 2007.
    Is it possible to customize the workflow or do you have to use the ones that are in the templates?

  7. THANK YOU VERY MUCH .THIS IS VERY USEFUL FOR UNDRSTANDING SHAREPOINT SERVER.CAN YOU PLEASE EXPLAIN HOW TO WRITE C# CODING IN SHAREPOINT WORKFLOW

  8. haaron,

    you mentioned that a developer can write a custom activity for sharepoint designer and use the SharePoint dll to create folders.

    Is the custom activity created in SharePoint Designer or in Visual Studio? How is this done?

    many thanks

    walt

  9. Use visual studio to create custom activities and also conditions the you will use in sharepoint designer when you are defining your workflow actions and conditions.

    Basically you create a class library project and create a class derive from activity, then you need to override some methods and create your own properties. Then you implement those methods with code, ussually we use the Microsoft.SharePoint.dll inside the activity in order to extend funcionality or behavior of a particular object of sharepoint. When you finish your dll you need to wrap this dll with a particular xml definition and store in some folder of sharepoint.

    Check this video: http://msdn2.microsoft.com/en-us/library/bb629922.aspx

    If you need help, pleas elet me know.

  10. Hi nice blog, then i have a question and i hope i you will answer me.
    if i need to add document to a document library with start and due-date and when due-date came i need this item to have a new permissions that now one can open it exclusive me.

Leave a Reply

Your email address will not be published. Required fields are marked *