Wednesday, July 9, 2008

How to Create a Simple Workflow in MOSS 2007?

What is Workflow?

A workflow as a business process, a chain of steps that need to be performed in order to accomplish a goal. Every business is filled with numerous processes whether it’s getting a contract approved, or processing an order from a catalog.

Windows workflows can be described as :

• Sequential Workflow
• State Machine Workflow

Sequential Work Flow

1. A Sequential Work Flow is a top-Down process, also known as a Human Flow Process, where the activities emerge from a beginning situation and end after a predefined sequence of steps.
2. Sequential Workflows are self-driven. Once they are initiated, they have an absolutely predictable behavior throughout the execution of the activities.

State Machine Workflow

1. The State Machine Workflow does not have a defined path but signifies a set of states and transitions between these states.
2. State Machine Workflows are event-driven. Activation of each state depends on predefined action / event. The engine executes the activities needed and stops after completion of the next state. State Machine Workflows are the solution for complex modeling processes where there is no deterministic execution path between the steps

How to Create Simple Workflow in MOSS 2007?

1. In the sharePoint site create two document library, One is called “Source Doc “ another one is called “Destination Doc" (How to create a document library?)

2. Upload the sample document in the source doc library. ((How to upload a document in document library?)




4. Create a Workflow project in Visual studio 2008.

Steps

a. Open up Visual Studio 2008.
b. Create a “New Project”.
c. Choose your language. I will be doing C#.
d. Select the Office, and then 2007.
e. Name your solution.
f. Click Ok.

5.Name the workflow and location for local debugging .

a. Enter the Workflow Name




b. Choose the location for local debugging of your workflow.



c. Click Next.

d. Set the list information based on the reference image.



e. Click Next.

f. Select the options based on the reference image.


g. Click Finish.

6. When your Visual Studio Solution is created (in Visual Studio 2008), you will get a project looks like this.








7. In the Projcet Three files are important such as Feature.xml,Key.snk and Worfklow.xml just refer these files in solution explorer .

8. When you open the Workflow1.cs “Design Surface”, as seen above you will see a single Workflow Activity called “OnWorkflowActivated1” For all intent and purposes, all workflows should start with this activity, and this activity will essentially “listen” for the event that SharePoint fires when your workflow should be started.

9. There are two properties that we need to pay some attention to with this Workflow Activity. They are the Correlation Token (CorrelationToken) and the Workflow Properties (WorkflowProperties).



10. In design surface we need to add two activity such as “Code Activity” and “Log History”.





11. After add these activity our workflow look like this.




12. Now we can add our workflow logic.

13. Double-click on the “OnWorkflowActivated1” activity, which will bring you to the code window.




14. Now we can add our logic part in code activity.




15. Double click the Code activity and enter the logic here.



16. Set the Log History in sharePoint. For this we can use the “log history” activity.



17. Now save the project and Deploy it. (Right click the Project in solution explorer -> select Deploy).

18. After success full deploy, then we set this workflow to the SharePoint “Source Doc” Library.



19. Set the unique name for this workflow.



20. Click Ok.



21. Now move to “Source Doc” and select or right click the uploaded Document.

22. From the pull down menu select the "Workflow".



23. In Workflow section, Select the Corresponding workflow for the Document.



24. Once the workflow is complete we can see the status as “Completed”



25. Then the uploaded document is copied in to the destination Document Library.



26. Now we can see the SharePoint Process History.








Hopefully you see how easy it is to build a very basic document workflow with Visual Studio 2008. I hope that you see the amount of code is minimal.With the advances in the Visual Studio 2008 IDE with respects to SharePoint workflow, debugging and deployment.


How to Create a List & Column in MOSS 2007?

No comments: