Tutorial Share Point Happy Birthday Workflow Slideshare
Embed Size (px)
Tutorial on creating a SharePoint workflow that sends a Happy Birthday card (as a content type) that is paritally populated using an InfoPath form. It is then emailed to the recipient of the card. The interesting part is the disabling of the InfoPath form once the workflow is completed by using a secondary data source.
Transcript of Tutorial Share Point Happy Birthday Workflow Slideshare
- 1. SlideShare.comSeptember 2009Tutorial Coding a SharePoint Happy Birthday Workflow with Visual Studio 2008Using an InfoPath Form for Input and Word Document as OutputGeorge Catrombon
Contents TOC o " 1-3" h z u SUMMARY PAGEREF _Toc241566766 h 3DESCRIPTION OF THE WORKFLOW PAGEREF _Toc241566768 h 3SUMMARY SNAPSHOTS OF OUR WORKFLOW PAGEREF _Toc241566769 h 4OVERVIEW OF THIS TUTORIAL PAGEREF _Toc241566770 h 12STEPS INVOLVED IN THE PROCESS PAGEREF _Toc241566771 h 12SOFTWARE REQUIRED TO DUPLICATE THIS PROJECT PAGEREF _Toc241566774 h 13STEP 1 CREATE A NEW LIBRARY IN SHAREPOINT PAGEREF _Toc241566775 h 13STEP 2 CREATE A TEMPLATE FOR THE BIRTHDAY CARD PAGEREF _Toc241566776 h 17STEP 3 CREATE THE WORD DOCUMENT FOR THE BIRTHDAY CARD FROM WITHIN THE LIBRARY PAGEREF _Toc241566779 h 20STEP 4 CREATE OUR INFOPATH 2007 FORM TO ACCEPT INPUT FROM THE USERS. PAGEREF _Toc241566787 h 35STEP 5 CODE OUR WORKFLOW IN VISUAL STUDIO PAGEREF _Toc241566794 h 70STEP 6 CONFIGURE WORKFLOW.XML AND FEATURE.XML IN VISUAL STUDIO PAGEREF _Toc241566798 h 92CONCLUSION PAGEREF _Toc241566799 h 95
This tutorial will demonstrate how to create a SharePoint sequential workflow that will reveal many useful techniques that can be applied in the field. The purpose of this workflow is to send a Birthday Card (as a Word document) via Email to a SharePoint user with some of the text of the Birthday Card filled out dynamically in C# code during the workflow. The dynamically populated fields will get their input from an InfoPath form presented to the person who is assigned the task of signing the card. This is similar to what might happen in an office today when your supervisor wants a person in his/her group to send a birthday card to a particular birthday boy or girl. In our situation, the supervisor creates the card from a SharePoint library as a Word document (as a content type) which has a workflow attached to it. The difference here is that the process is under the management of the workflow which we will code in Visual Studio 2008.
Note: This is a long tutorial with a vast number of steps required to complete it. The reader should be alert to how complex the process is to create a very simple sequential workflow that does some fancy work behind the scenes using InfoPath forms.
DESCRIPTION OF THE WORKFLOW
Lets take a moment to better describe what we want. A birthday card will be created as a content type for a SharePoint library that we will create. We will call the library Happy Birthday Card Library. A birthday card will be a Word document, with a picture of a birthday cake, and several pre-defined fields as Word properties which are linked to column types in the library. Some of these fields will be filled out by the initiator of the birthday card (the supervisor most likely) which will include the name of the recipient (E.g. Jane Smith), an opening greeting (E.g. Best wishes on your Birthday!), the email address of the recipient, and the login name of the person assigned the task of signing the card (E.g. JohnDoe@yourdomain.com). There will then be two additional fields which need to be populated by the signer of the card. These two fields are filled out by using an InfoPath form. These fields are from (E.g. John) and the message the signer would like to include (E.g. Hope you like the cake!). When the signer completes the workflow task, the workflow will finish populating the Word document Birthday Card with the two fields obtained from the InfoPath form, and then email the updated Birthday Card to the recipient as an email attachment. The workflow will then mark the task as completed. The other thing we will do is disable the submit button on the InfoPath form when the workflow task is completed. If we did not do this, then the user could re-submit the form again and again from the Tasks page. There will have to be a feedback mechanism for the InfoPath form to make it aware that the task was completed. We disable the submit button in this example.
SUMMARY SNAPSHOTS OF OUR WORKFLOW
For reference, the snapshots below summarize the procedure of sending the birthday card.
- Administrator creates a Birthday Card (Figure 1)
- Administrator fills out 4 properties of the Word document (Figure 2)
Note that Mary Smith was assigned the task of signing the card (E.g. Assigned To Login Name = MY_NETBIOS_NAMEmarysmith in the property field Figure 2)
- Exit Word (Figure 3)
- Birthday Card is saved in the SharePoint Library (Figure 4)
Workflow is stated automatically on save. ( Figure 5)
Figure 5 Our workflow has started.
We now sign in as Mary Smith, signer of the card. The task is present on her task list. (Figure 6)
Figure 6 We are now signed in as Mary Smith
Mary clicks Please sign this birthday card and gets the InfoPath form which she fills out 2 fields. (Figure 7)
Figure 7 Mary fills out the form.
Mary clicks the submit button and the task completes. (Figure 8)
Figure 8 Task completed!
Recipient of the card gets an email with the filled out Birthday Card. (figure 9 & 10)
Word document is fully populated by our Workflow. (Figure 11)
Figure 11 Card filled out by the Workflow!
- Notice that we disable the Submit button in the InfoPath form if Mary tries to fill it out a 2nd time. (Figure 12).
So, thats the flow. Its very simple from the users perspective. However, to get all this working requires a considerable amount of knowledge and work. Lets get started.
OVERVIEW OF THIS TUTORIAL
This tutorial has a huge number steps that need to be performed to set up this workflow. There is very little C# code in the Workflow, and most of the work is done outside of the workflow programming in preparation. Also, this tutorial is quite long since there are so many pieces that need to be discussed to get all of this to work together. Also, there are some issues that would need to be addressed in a production environment. One of them is that we only have one Word document Birthday Card in our SharePoint library. Our C# code references this Word document by its filename and is hard coded. We would need to enhance the C# code to allow any filename to be used for a Birthday Card. One way to do this is to include another property on the Birthday Card Word document named Filename which the initiator of the card would fill out. Another issue is that our InfoPath form takes over the page where a user would normally change the % complete and status of the Workflow. That is why we update the completed status in the Workflow rather than let the user do it manually. Students of SharePoint Minds are encouraged to modify this Workflow to address those issues.
In any event, this tutorial has a wealth of good information regarding SharePoint workflows that would be helpful.
STEPS INVOLVED IN THE PROCESS
To create this work flow, we have to perform the following steps:
- Create a new library in SharePoint named Happy Birthday Card Library.
- 2. Create a template for the Birthday Card in the library by defining new columns.
- 3. Create the Word document Birthday Card.
- 4. Add the Birthday Card as a content type to the library.
- 5. Create our InfoPath 2007 task form to accept user input for the From and Message fields.
- 6. Configure the InfoPath form to receive feedback from the workflow by specifying a secondary data source.
- 7. Configure the InfoPath form to be presented in a web page with Full Trust security and temporary certificate.
- 8. Code the Workflow using Visual Studio 2008 in C#.
- 9. Configure the Workflow in Visual Studio to include the InfoPath form as part of the deployment.
- 10. Configure the Workflow.xml file so that our InfoPath form is presented to the user in a web page.
- 11. Configure feature.xml so that our InfoPath form is deployed as a feature.
SOFTWARE REQUIRED TO DUPLICATE THIS PROJECT
The software requirements for this project are significant. The software that you will need is as per the following list:
- Microsoft ASP.NET 3.5 Framework
- 12. Microsoft Windows Server 2003 installed on the Virtual Machine (E.g. the VM)