<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.sharepointblogs.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Andrew Noon&amp;#39;s Blog</title><link>http://www.sharepointblogs.com/andynoon/default.aspx</link><description>SharePoint, MOSS 2007, Information Architecture, Business Intelligence and other rambling</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP2 (Build: 20611.960)</generator><item><title>SQL Server 2005 &amp; Visual Studio 2008</title><link>http://www.sharepointblogs.com/andynoon/archive/2008/06/15/sql-server-2005-amp-visual-studio-2008.aspx</link><pubDate>Sun, 15 Jun 2008 00:02:00 GMT</pubDate><guid isPermaLink="false">1f6a1193-f4bb-4480-a5ae-b538d8b20f46:17612</guid><dc:creator>Andrew Noon</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.sharepointblogs.com/andynoon/rsscomments.aspx?PostID=17612</wfw:commentRss><comments>http://www.sharepointblogs.com/andynoon/archive/2008/06/15/sql-server-2005-amp-visual-studio-2008.aspx#comments</comments><description>&lt;p&gt;I was having untold problems installing a new VM.&amp;nbsp; Windows 2008 with MOSS 2007, Visual Studio 2008 and SQL Server 2005.&amp;nbsp; Because I was building in that order I kept having problems after installing SQL Server.&amp;nbsp; Basically it didn&amp;#39;t install the Management Studio or add the shortcut to the start menu.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I tried for a long time to figure the problem out before I stumbled on a solution.&amp;nbsp; If you change the directory name C:\Program Files\Microsoft SQL Server\90\Tools before you do the SQL install (it&amp;#39;s there because VS 2008 intsalls SQL Express) then the SQL install works fine and installs the Management Studio.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I can only think that the SQL install finds the tools directory and then just assumes it doesn&amp;#39;t need to do that bit of the install.&amp;nbsp; More likely it tries to create the directory, get a DIRECTORYEXISTS exception and tries to resume.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Copy the old tools files back the the new tools directory when you&amp;#39;re finished otherwise you might find VS has some problems!&lt;/p&gt;
&lt;p&gt;Anyway, hope this help someone - I found nothing on google - maybe I&amp;#39;m the only one ;-)&lt;/p&gt;Content by : Andrew Noon
			&lt;hr&gt;&lt;span style="font-size:10pt;"&gt;Posted on &lt;a href="http://www.sharepointblogs.com/"&gt;SharePoint Blogs&lt;/a&gt;&lt;/span&gt;
		  &lt;img src="http://www.sharepointblogs.com/aggbug.aspx?PostID=17612" width="1" height="1"&gt;</description></item><item><title>Everyone wants one!</title><link>http://www.sharepointblogs.com/andynoon/archive/2008/03/20/everyone-wants-one.aspx</link><pubDate>Thu, 20 Mar 2008 12:28:00 GMT</pubDate><guid isPermaLink="false">1f6a1193-f4bb-4480-a5ae-b538d8b20f46:14331</guid><dc:creator>Andrew Noon</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.sharepointblogs.com/andynoon/rsscomments.aspx?PostID=14331</wfw:commentRss><comments>http://www.sharepointblogs.com/andynoon/archive/2008/03/20/everyone-wants-one.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;ve written so many SharePoint asset viewer type web parts (or applications) over the last few years I thought it was about time I blogged some code to get you started yourselves, the following will render a simple treeview that will allow you to traverse through your SharePoint site and sub sites and see what lists, libraries, users etc are in each site.&lt;/p&gt;&lt;pre class="csharpcode"&gt;  &lt;a href="http://www.clearchaos.net/AndysBlogImages/Everyonewantsone_BDB3/image.png"&gt;&lt;img style="BORDER-TOP-WIDTH:0px;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" border="0" alt="image" src="http://www.clearchaos.net/AndysBlogImages/Everyonewantsone_BDB3/image_thumb.png" width="354" height="498" /&gt;&lt;/a&gt;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// PopulateTreeView is a recursive function, starting at the supplied SPWeb parameter it will extract all relevant information from the site before recirsing for each sub site.&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;web&amp;quot;&amp;gt;web is the starting SPWeb (SharePoint web site) for the function.  In this case the current site i.e. the site on which the web part is placed.&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;protected&lt;/span&gt; TreeNode PopulateTreeView(SPWeb web)
        {
            TreeNode top = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (web != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
            {
                &lt;span class="rem"&gt;//get detail of this current web&lt;/span&gt;
                top = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(&lt;span class="str"&gt;&amp;quot;Site Details(&amp;quot;&lt;/span&gt; + web.Title + &lt;span class="str"&gt;&amp;quot;)&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;0&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;/_layouts/images/SPHOMESM.GIF&amp;quot;&lt;/span&gt;, web.Url, &lt;span class="str"&gt;&amp;quot;_blank&amp;quot;&lt;/span&gt;);
                TreeNode node = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(web.Title, &lt;span class="str"&gt;&amp;quot;root&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;/_layouts/images/ICHTT.GIF&amp;quot;&lt;/span&gt;, web.Url, &lt;span class="str"&gt;&amp;quot;_blank&amp;quot;&lt;/span&gt;);
                node.ChildNodes.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(&lt;span class="str"&gt;&amp;quot;URL: &amp;quot;&lt;/span&gt; + web.Url, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;/_layouts/images/NEWLINK.GIF&amp;quot;&lt;/span&gt;, web.Url, &lt;span class="str"&gt;&amp;quot;_blank&amp;quot;&lt;/span&gt;));
                TreeNode users = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(&lt;span class="str"&gt;&amp;quot;Users&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;/_layouts/images/stsicon.gif&amp;quot;&lt;/span&gt;);
                &lt;span class="rem"&gt;//get all admins&lt;/span&gt;
                TreeNode admins = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(&lt;span class="str"&gt;&amp;quot;Administrators (&amp;quot;&lt;/span&gt; + web.SiteAdministrators.Count + &lt;span class="str"&gt;&amp;quot;)&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;/_layouts/images/STSPEOPL.GIF&amp;quot;&lt;/span&gt;);
                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (SPUser user &lt;span class="kwrd"&gt;in&lt;/span&gt; web.SiteAdministrators)
                {
                    TreeNode usr = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(user.LoginName + &lt;span class="str"&gt;&amp;quot;(&amp;quot;&lt;/span&gt; + user.Email + &lt;span class="str"&gt;&amp;quot;)&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;/_layouts/images/STAR.GIF&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;mailto:&amp;quot;&lt;/span&gt; + user.Email, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);
                    admins.ChildNodes.Add(usr);
                }
                users.ChildNodes.Add(admins);
                &lt;span class="rem"&gt;//get all groups and users within those groups&lt;/span&gt;
                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (SPGroup group &lt;span class="kwrd"&gt;in&lt;/span&gt; web.Groups)
                {
                    &lt;span class="rem"&gt;//record this group&lt;/span&gt;
                    TreeNode grp = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(group.Name + &lt;span class="str"&gt;&amp;quot; (&amp;quot;&lt;/span&gt; + group.Users.Count + &lt;span class="str"&gt;&amp;quot;)&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;/_layouts/images/STSPEOPL.GIF&amp;quot;&lt;/span&gt;);
                    &lt;span class="rem"&gt;//for for each user in this group&lt;/span&gt;
                    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (SPUser user &lt;span class="kwrd"&gt;in&lt;/span&gt; group.Users)
                    {
                        &lt;span class="rem"&gt;//record this user&lt;/span&gt;
                        TreeNode usr = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(user.LoginName + &lt;span class="str"&gt;&amp;quot;(&amp;quot;&lt;/span&gt; + user.Email + &lt;span class="str"&gt;&amp;quot;)&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;/_layouts/images/mysite_titlegraphic.gif&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;mailto:&amp;quot;&lt;/span&gt; + user.Email, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);
                        grp.ChildNodes.Add(usr);
                    }
                    users.ChildNodes.Add(grp);
                }
                node.ChildNodes.Add(users);
                &lt;span class="rem"&gt;//get all lists (includes document libraries, discussion forums...)&lt;/span&gt;
                TreeNode lists = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(&lt;span class="str"&gt;&amp;quot;Lists and libraries (&amp;quot;&lt;/span&gt; + web.Lists.Count + &lt;span class="str"&gt;&amp;quot;)&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;/_layouts/images/sts_list16.gif&amp;quot;&lt;/span&gt;);
                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (SPList list &lt;span class="kwrd"&gt;in&lt;/span&gt; web.Lists)
                {
                    TreeNode lst = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
                    &lt;span class="kwrd"&gt;try&lt;/span&gt;
                    {
                        &lt;span class="rem"&gt;//an exception can be thrown if an attempt to get the amount of items in a list returns null, also if the list is partially defines an exception may be thrown&lt;/span&gt;
                        lst = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(list.Title + &lt;span class="str"&gt;&amp;quot; (&amp;quot;&lt;/span&gt; + list.ItemCount + &lt;span class="str"&gt;&amp;quot; items)&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;/_layouts/images/iKpiList.png&amp;quot;&lt;/span&gt;, list.DefaultViewUrl, &lt;span class="str"&gt;&amp;quot;_blank&amp;quot;&lt;/span&gt;);
                    }
                    &lt;span class="kwrd"&gt;catch&lt;/span&gt;(Exception)
                    {
                        &lt;span class="rem"&gt;//if the exception (above) was thrown, just record the name of the list (ignore the amount of items)&lt;/span&gt;
                        lst = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(list.Title);
                    }
                    lists.ChildNodes.Add(lst);
                }
                node.ChildNodes.Add(lists);
                &lt;span class="rem"&gt;//recurse for each sub web of the current web&lt;/span&gt;
                TreeNode webs = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(&lt;span class="str"&gt;&amp;quot;Sub Webs (&amp;quot;&lt;/span&gt; + web.Webs.Count + &lt;span class="str"&gt;&amp;quot;)&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;/_layouts/images/SITEVARIATION.GIF&amp;quot;&lt;/span&gt;);
                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (SPWeb subweb &lt;span class="kwrd"&gt;in&lt;/span&gt; web.Webs)
                {
                    webs.ChildNodes.Add(PopulateTreeView(subweb));
                }
                node.ChildNodes.Add(webs);
                top.ChildNodes.Add(node);
            }
            &lt;span class="rem"&gt;//return the complete node&lt;/span&gt;
            &lt;span class="kwrd"&gt;return&lt;/span&gt; top;
        }&lt;/pre&gt;Content by : Andrew Noon
			&lt;hr&gt;&lt;span style="font-size:10pt;"&gt;Posted on &lt;a href="http://www.sharepointblogs.com/"&gt;SharePoint Blogs&lt;/a&gt;&lt;/span&gt;
		  &lt;img src="http://www.sharepointblogs.com/aggbug.aspx?PostID=14331" width="1" height="1"&gt;</description><category domain="http://www.sharepointblogs.com/andynoon/archive/tags/MOSS+2007/default.aspx">MOSS 2007</category><category domain="http://www.sharepointblogs.com/andynoon/archive/tags/SharePoint+Portal+Server+2003/default.aspx">SharePoint Portal Server 2003</category></item><item><title>Collecting data from users in SharePoint workflow's created in Visual Studio 2008</title><link>http://www.sharepointblogs.com/andynoon/archive/2008/02/11/collecting-data-in-custom-sharepoint-workflows.aspx</link><pubDate>Mon, 11 Feb 2008 14:40:00 GMT</pubDate><guid isPermaLink="false">1f6a1193-f4bb-4480-a5ae-b538d8b20f46:12545</guid><dc:creator>Andrew Noon</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.sharepointblogs.com/andynoon/rsscomments.aspx?PostID=12545</wfw:commentRss><comments>http://www.sharepointblogs.com/andynoon/archive/2008/02/11/collecting-data-in-custom-sharepoint-workflows.aspx#comments</comments><description>&lt;p&gt;In my previous blog entry I explained how to create a workflow for SharePoint using Visual Studio 2008. It was a simple workflow designed to get you started, but what happens when that&amp;#8217;s not enough? Well the next, most natural step is to collect information from users and to utilise that data in your workflow. I&amp;#39;ve seen a lot of examples that tell you how to collect data using one mechanism or another but none that bring them together or that describe each step in great detail (idiots guide).&amp;#160; Since I&amp;#39;m the sort of person that needs to know EXACTLY how each step works and why here&amp;#39;s my guide to collecting data from users in a workflow&lt;/p&gt;  &lt;p&gt;If you haven&amp;#39;t &amp;#39;done&amp;#39; workflow before then read my first blog before reading any further: &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;When can I collect data?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can collect data at any time during your workflow using tasks, SharePoint provides a custom list to help with this, called a Task List. At any point in your workflow you can opt to collect data from the user by assigning a task to them. Additionally there are specific points in the workflow&amp;#39;s lifecycle where you can interrupt workflow execution to collect data from the user, these can be surmised as:&lt;/p&gt;  &lt;table class="" cellspacing="2" cellpadding="2"&gt;     &lt;tr&gt;       &lt;td class=""&gt;&lt;b&gt;Event name&lt;/b&gt;&lt;/td&gt;        &lt;td class=""&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/td&gt;        &lt;td class=""&gt;&lt;b&gt;Further reading&lt;/b&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class=""&gt;Association&lt;/td&gt;        &lt;td class=""&gt;Occurs when a site administrator first adds the workflow to a library (makes an &lt;i&gt;association &lt;/i&gt;between the library and workflow)&lt;/td&gt;        &lt;td class=""&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms481192.aspx"&gt;Click here...&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class=""&gt;Instantiation&lt;/td&gt;        &lt;td class=""&gt;Occurs when the workflow starts. For example, if your workflow is set to start automatically when a new item is created in a library then it is when the item is created that this will occur.&lt;/td&gt;        &lt;td class=""&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms481192.aspx"&gt;Click here...&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class=""&gt;Modification&lt;/td&gt;        &lt;td class=""&gt;Allows a user to modify your workflow during its processing. You can associate a form to a particular section of processing; this form is made available to the user via the workflow status page. Typically this might allow a user to reassign a task to someone else.&lt;/td&gt;        &lt;td class=""&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms480794.aspx"&gt;Click here...&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class=""&gt;Task&lt;/td&gt;        &lt;td class=""&gt;This is defined in your workflow. You insert a task creation step in your workflow and wait for the task to be completed.&lt;/td&gt;        &lt;td class=""&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms438856.aspx"&gt;Click here...&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p align="right"&gt;Table 1 &amp;#8211; Event types&lt;/p&gt;  &lt;p&gt;Each of the event shown in &lt;i&gt;Table 1&lt;/i&gt; can be associated with a form so that when the event fires the specified form is loaded and displayed to the user. There is both an easy way and a hard(harder) way of achieving this. Here I will introduce both methods and show the reader how it can be achieved.&lt;/p&gt;  &lt;p&gt;In my workflow example I want to move a document from its current location to the document centre library in my top level site. In addition when the workflow is first associated with a library I want to ask the user who needs to approve the document before it is moved and whether a marker (gravestone) should be created in the current site to indicate that the document used to exist in this location but has been moved to the document centre.&lt;/p&gt;  &lt;h4&gt;Using InfoPath Forms to collect data&lt;/h4&gt;  &lt;p&gt;If you have Microsoft Office SharePoint Server (MOSS) Enterprise Edition you can use InfoPath forms to collect and process data, including receiving data from and passing data back to the workflow. However if you are not running MOSS Enterprise Edition or are just using Windows SharePoint Services (WSS) then you&amp;#8217;ll want to skip this section and go straight to the ASPX forms explanation.&lt;/p&gt;  &lt;h5&gt;Create the form&lt;/h5&gt;  &lt;p&gt;InfoPath allows you to create forms in a graphical environment and then save the form to SharePoint where it can be opened up either as a web page or through the InfoPath client application. Let&amp;#8217;s go ahead and create a form to show our user when we first associate the workflow with a library. Open InfoPath and choose to &amp;#8216;design a form template&amp;#8217;, then select the blank template option.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image004.gif"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="162" alt="clip_image004" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image004_thumb.gif" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="right"&gt;Figure 1 - Creating the InfoPath form&lt;/p&gt;  &lt;p&gt;Now we have our basic form, let&amp;#8217;s apply some simple styling and add some fields. You&amp;#8217;ll notice from my screenshot that I&amp;#8217;m using a contact selector control that is not a standard part of the InfoPath controls library. You can either leave it out to keep things simple or learn how to do this here &lt;a href="http://msdn2.microsoft.com/en-us/library/ms558892.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms558892.aspx&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image006.gif"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="115" alt="clip_image006" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image006_thumb.gif" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="right"&gt;Figure 2 - The association form&lt;/p&gt;  &lt;p&gt;The finish button will need to submit the form to the host environment and then close the form. This is a simple task, from the button properties add a rule and then add actions to submit the data (when prompted add a submit task to send data &amp;#8216;to the hosting environment, such as...&amp;#8217;). Then add another action to close the form.&lt;/p&gt;  &lt;h5&gt;Publish the form&lt;/h5&gt;  &lt;p&gt;Don&amp;#8217;t forget to make the form browser compatible - in the compatibility section of form options (from the tools menu) check the check the box to allow browser compatibility forms. Then in the Security and Trust section of Form Options set the forms security level to domain, otherwise the form will not run from within SharePoint. It&amp;#8217;s also good practise to digitally sign the form but not essential for this process. We can now go ahead and publish the form, use the publish option in the file menu to publish to a network location. To keep things simple publish the form to the same directory as your workflow project files, doing this will mean that the form is installed automatically without having to edit the features.xml file. On the next screen, deleted the suggested entry in the alternate path textbox, this will give the warning below but click Ok and continue to publish the form.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image008.gif"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="48" alt="clip_image008" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image008_thumb.gif" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="right"&gt;Figure 3 - Alternate access working (ignore)&lt;/p&gt;  &lt;h5&gt;Associate the form with the workflow&lt;/h5&gt;  &lt;p&gt;Now that the form is published we can add it to our workflow. To do this open up the workflow you want it associating with and open the workflow.xml. SharePoint has a page that is used to host InfoPath forms for each of the workflow events we discussed earlier, except the custom task (we will discuss the reason for that later).&lt;/p&gt;  &lt;table class="" cellspacing="2" cellpadding="2"&gt;     &lt;tr&gt;       &lt;td class=""&gt;&lt;b&gt;Event name&lt;/b&gt;&lt;/td&gt;        &lt;td class=""&gt;&lt;b&gt;XML tag&lt;/b&gt;&lt;/td&gt;        &lt;td class=""&gt;         &lt;p&gt;&lt;b&gt;SharePoint host page&lt;/b&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class=""&gt;&lt;b&gt;Association&lt;/b&gt;&lt;/td&gt;        &lt;td class=""&gt;AssociationUrl&lt;/td&gt;        &lt;td class=""&gt;         &lt;p&gt;CstWrkflIP.aspx&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class=""&gt;&lt;b&gt;Instantiation&lt;/b&gt;&lt;/td&gt;        &lt;td class=""&gt;InstantiationUrl&lt;/td&gt;        &lt;td class=""&gt;IniWrkflIP.aspx&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class=""&gt;&lt;b&gt;Modification&lt;/b&gt;&lt;/td&gt;        &lt;td class=""&gt;ModificationUrl&lt;/td&gt;        &lt;td class=""&gt;ModWrkflIP&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p align="right"&gt;Table 2 - Form host pages&lt;/p&gt;  &lt;p&gt;We also need to tell the host page which form we want to be displayed, so we&amp;#8217;ll need the unique identifier that was applied to our form when we published it. If you open the form back up in design mode and look at the file properties you&amp;#8217;ll see the form ID. Copy it to the clip board and sue it to make your workflow.xml looks similar to the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image010.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="85" alt="clip_image010" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image010_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="right"&gt;Figure 4 - workflow.xml&lt;/p&gt;  &lt;h5&gt;Integrate the form data&lt;/h5&gt;  &lt;p&gt;So, if we deployed and ran out workflow we would now find that the form is displayed! BUT before we do that we really want to be able to respond to the data that&amp;#8217;s been supplied from within our workflow. There&amp;#8217;s a bit of magic here firstly in the host page (and InfoPath form) that will automatically handle sending the data through to our workflow. The other piece of magic needs some work, when we get hold of the data it is nothing more than XML but I find it much easier to work with an object that parsing through XML. We can automatically create a class to squirt the XML into using our forms data source. Back in InfoPath, in design view, select file and save source files. Save them to a new directory in the directory that holds your form. From the files (or one of them) that are produced we can use a nifty .NET utility called XSD to automatically create a class that represents all the data in our form. You&amp;#8217;ll need the SDK for .NET to get hold of XSD and can download it from here &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=C2B1E300-F358-4523-B479-F53D234CDCCF&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=C2B1E300-F358-4523-B479-F53D234CDCCF&amp;amp;displaylang=en&lt;/a&gt;. Running the following command will write a new class to the same directory as your XSN file:&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;xsd myschema.xsd /classes&lt;/pre&gt;
&lt;/div&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }

&lt;p align="right"&gt;Figure 5 - Creating a class from XSN&lt;/p&gt;

&lt;p&gt;Now add this class to your workflow project and add code similar to that below to extract the initiation data from into your workflow:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;XmlSerializer serialiser = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(associationFields));&lt;/pre&gt;

  &lt;pre&gt;XmlTextReader reader = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextReader(&lt;span class="kwrd"&gt;new&lt;/span&gt; System.IO.StringReader(workflowProperties.InitiationData));&lt;/pre&gt;

  &lt;pre class="alt"&gt;XmlSerializer serialiser = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(myFields));&lt;/pre&gt;

  &lt;pre&gt;associationFields initData = (associationFields)serialiser.Deserialize(reader);&lt;/pre&gt;

  &lt;pre class="alt"&gt;_approver = initData.contact[0];&lt;/pre&gt;

  &lt;pre&gt;_addGraveStone = (&lt;span class="kwrd"&gt;bool&lt;/span&gt;)initData.gravestone;&lt;/pre&gt;
&lt;/div&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }

&lt;p align="right"&gt;Figure 5b - Creating a class from XSN&lt;/p&gt;

&lt;h5&gt;Deploy the workflow&lt;/h5&gt;

&lt;p&gt;So, that&amp;#8217;s it &amp;#8211; your workflow works and you&amp;#8217;re ready to deploy. This is the easy bit! In essence the deployment of your workflow has already happened, if you&amp;#8217;re using Visual Studio 2008 the workflow will have been automatically deployed to the site collection you specified as the development site when you first created the workflow project. However should you need to deploy the workflow to a different server or site collection then these are the steps that you&amp;#8217;ll need.&lt;/p&gt;

&lt;p&gt;The following steps will deploy your workflow to a site collection.&lt;/p&gt;

&lt;p&gt;1. Copy the DLL your workflow creates from the build directory (\bin\Debug) to the Global Assembly Cache (GAC)&lt;/p&gt;

&lt;p&gt;2. Create a directory in the features directory [C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\TEMPLATE\FEATURES] and drop both the feature.xml and workflow.xml files into the directory.&lt;/p&gt;

&lt;p&gt;3. Install the feature on your farm, using the following command line statements&lt;/p&gt;

&lt;p class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;p&gt;stsadm -o installfeature -name DocumentMoveAndShortcut&lt;/p&gt;&lt;/pre&gt;
&lt;/p&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }

&lt;p align="right"&gt;Figure 6 - Install the feature&lt;/p&gt;

&lt;p&gt;4. Activate the feature to a site collection&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;stsadm -o activatefeature &amp;#8211;name DocumentMoveAndShortcut -url http://moss2007win2008&lt;/pre&gt;
&lt;/div&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }

&lt;p align="right"&gt;Figure 7 - Activate the feature&lt;/p&gt;

&lt;p&gt;&lt;b&gt;NOTE&lt;/b&gt;: You can usually find the STSADM command in the directory C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\BIN&lt;/p&gt;

&lt;h5&gt;Test&lt;/h5&gt;

&lt;p&gt;When you associate your workflow with a document library you should now see your association form, looking something like that below and your data should be sent into your workflow!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image012.gif"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="161" alt="clip_image012" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image012_thumb.gif" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="right"&gt;Figure 8 - InfoPath association form&lt;/p&gt;

&lt;h4&gt;Using ASPX Forms to collect data&lt;/h4&gt;

&lt;p&gt;For this example we&amp;#8217;ll extend our workflow to assign a task to a user and collect data from that user when they edit the task. In my example I&amp;#8217;m going to use that task as a form of crude approval. I&amp;#8217;m going to ask a user (the user I captured in the association form) to approve the item. Once the item is approved I will move the document and if the association form requested a gravestone then I&amp;#8217;ll add an item to a list on the site to indicate that the document has been moved.&lt;/p&gt;

&lt;h5&gt;Create the form&lt;/h5&gt;

&lt;p&gt;Open your work flow in Visual Studio 2008 and add a new web site project to your solution, you project should be created in the _layouts directory as indicated in the following screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image014.gif"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="172" alt="clip_image014" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image014_thumb.gif" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="right"&gt;Figure 9 - Creating the ASPX form&lt;/p&gt;

&lt;p&gt;It&amp;#8217;s probably a good idea to delete the default.aspx file that is created since we don&amp;#8217;t need it. Create a new Web Form (Website -&amp;gt; Add New Item) I&amp;#8217;ll name mine &amp;#8216;DocumentApprovalTask.aspx. Since our page needs to be a &amp;#8216;SharePoint page&amp;#8217; you can delete everything in the page with the exception of the first line, the page declaration. We can now put the bare bones to our page, I won&amp;#8217;t go into excessive detail about this but at a high level we need to tell the page to use SharePoints&amp;#8217; application master page, add some reference to SharePoint and put content placeholders in.&lt;/p&gt;

&lt;p&gt;You will not be able to design this page in design view as the masterpage directive will only work when the page is running within the context of the SharePoint web application. We will rely on your HTML / ASP skills to put this page together but if you wanted to you could create a new page use that to design the page and then paste the HTML code into the task page. Your HTML code should look like:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="asp"&gt;&amp;lt;%@ Page Language=&amp;quot;C#&amp;quot; AutoEventWireup=&amp;quot;true&amp;quot; MasterPageFile=&amp;quot;~/_layouts/application.master&amp;quot; CodeFile=&amp;quot;DocumentApprovalTask.aspx.cs&amp;quot; Inherits=&amp;quot;DocumentApprovalTask&amp;quot; %&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="asp"&gt;&amp;lt;%@ Register Tagprefix=&amp;quot;SharePoint&amp;quot; Namespace=&amp;quot;Microsoft.SharePoint.WebControls&amp;quot; Assembly=&amp;quot;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;quot; %&amp;gt;&lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="asp"&gt;&amp;lt;%@ Register Tagprefix=&amp;quot;Utilities&amp;quot; Namespace=&amp;quot;Microsoft.SharePoint.Utilities&amp;quot; Assembly=&amp;quot;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;quot; %&amp;gt;&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Content&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;PageTitle&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;contentplaceholderid&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;PlaceHolderPageTitle&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;Approval Task&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Content&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;PageTitleInTitleArea&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;contentplaceholderid&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;PlaceHolderPageTitleInTitleArea&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;Document Approval Task&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Content&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;contentplaceholderid&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;PlaceHolderMain&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;h1&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Task Notification&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;h1&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt; &lt;span class="attr"&gt;colspan&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;b&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;You have been assigned a task to approve the following document. Approving the document will result in the move of the document from its current location to the document centre.&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;b&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Document Name&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;lblDocName&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Document URL&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;lblDocURL&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Do you approve this action?&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:CheckBox&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;chkApproved&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Checked&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt; &lt;span class="attr"&gt;colspan&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;align&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;right&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;br&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Button&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;btnSubmit&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;OnClick&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;btnSubmit_Click&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Complete&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:FormDigest&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;taskPost&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;SharePoint:FormDigest&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }

&lt;p align="right"&gt;Figure 10 - The bare ASPX page&lt;/p&gt;

&lt;p&gt;You&amp;#8217;ll notice from this that I have controls that will accept data from our workflow (document name and URL) and a control to accept data from the user (approval). Both of these are easy enough, if you use the following code to insert into your code behind that&amp;#8217;s the ASPX form complete.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.SharePoint;
&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.SharePoint.WebControls;
&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.SharePoint.Workflow;
&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.SharePoint.Utilities;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; DocumentApprovalTask : System.Web.UI.Page
{
    SPWeb _web;
    SPList _taskList;
    SPListItem _taskItem;
    SPWorkflow _workflow;
    Guid _workflowID;
    &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Page_Load(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
    {
        &lt;span class="rem"&gt;//get task data&lt;/span&gt;
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._web = SPControl.GetContextWeb(Context);
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._taskList = &lt;span class="kwrd"&gt;this&lt;/span&gt;._web.Lists[&lt;span class="kwrd"&gt;new&lt;/span&gt; Guid(Request.Params[&lt;span class="str"&gt;&amp;quot;List&amp;quot;&lt;/span&gt;])];
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._taskItem = 
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._taskList.GetItemById(System.Convert.ToInt16(Request.Params[&lt;span class="str"&gt;&amp;quot;ID&amp;quot;&lt;/span&gt;]));
        &lt;span class="rem"&gt;//get workflow data&lt;/span&gt;
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._workflowID = &lt;span class="kwrd"&gt;new&lt;/span&gt; 
        Guid(Convert.ToString(&lt;span class="kwrd"&gt;this&lt;/span&gt;._taskItem[&lt;span class="str"&gt;&amp;quot;WorkflowInstanceID&amp;quot;&lt;/span&gt;]));
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._workflow = &lt;span class="kwrd"&gt;new&lt;/span&gt; SPWorkflow(&lt;span class="kwrd"&gt;this&lt;/span&gt;._taskItem, &lt;span class="kwrd"&gt;this&lt;/span&gt;._workflowID);
        lblTitle.Text = &lt;span class="kwrd"&gt;this&lt;/span&gt;._taskItem[&lt;span class="str"&gt;&amp;quot;Title&amp;quot;&lt;/span&gt;].ToString();
        lblDocName.Text = &lt;span class="kwrd"&gt;this&lt;/span&gt;._taskItem[&lt;span class="str"&gt;&amp;quot;Document Name&amp;quot;&lt;/span&gt;].ToString();
        lblDocURL.Text = &lt;span class="kwrd"&gt;this&lt;/span&gt;._taskItem[&lt;span class="str"&gt;&amp;quot;Document URL&amp;quot;&lt;/span&gt;].ToString();
        lblAssignee.Text = &lt;span class="kwrd"&gt;this&lt;/span&gt;._taskItem[&lt;span class="str"&gt;&amp;quot;Assigned To&amp;quot;&lt;/span&gt;].ToString();
    }
    &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; btnSubmit_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
    {
        Hashtable hash = &lt;span class="kwrd"&gt;new&lt;/span&gt; Hashtable();
        hash[&lt;span class="str"&gt;&amp;quot;MoveApproved&amp;quot;&lt;/span&gt;] = chkApproved.Checked;
        hash[&lt;span class="str"&gt;&amp;quot;TaskStatus&amp;quot;&lt;/span&gt;] = &lt;span class="str"&gt;&amp;quot;Complete&amp;quot;&lt;/span&gt;;
        hash[&lt;span class="str"&gt;&amp;quot;PercentComplete&amp;quot;&lt;/span&gt;] = &lt;span class="str"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;;
        SPWorkflowTask.AlterTask(&lt;span class="kwrd"&gt;this&lt;/span&gt;._taskItem, hash, &lt;span class="kwrd"&gt;true&lt;/span&gt;);
        SPUtility.Redirect(&lt;span class="kwrd"&gt;this&lt;/span&gt;._TaskListAttachedTo.DefaultViewUrl, 
        SPRedirectFlags.UseSource, HttpContext.Current);
    }
}&lt;/pre&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }

&lt;p align="right"&gt;Figure 11 - Form code behind file&lt;/p&gt;

&lt;h5&gt;Create a content type&lt;/h5&gt;

&lt;p&gt;All tasks in SharePoint have to be defined as a content type. Again, I won&amp;#8217;t go into the detail of what a content type is and how it works but if you want to do some research you can start here &amp;#8211; &lt;a href="http://msdn2.microsoft.com/en-us/library/ms472236.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms472236.aspx&lt;/a&gt;. A content type has at least 3 files, a features file that tells SharePoint what files to expect in the content type feature, a content type file that describes, well &amp;#8211; the content type. Finally, a columns or fields file that describes each of the columns in our content type. Let&amp;#8217;s work backwards and start with the columns file. For each filed you want in your content type (either for displaying to the user or collecting from the user you will need to add a &amp;lt;field&amp;gt; entry and each field needs a unique ID (use the Create GUID option in Visual Studio&amp;#8217;s Tools menu). There are some fields that will be automatically available because we will later tell SharePoint that our content type inherits the default behaviour of a task content type (these are fields such as PercentComplete, Title, Approved, Assigned To...). &lt;i&gt;Table 12 &lt;/i&gt;shows my columns file, I&amp;#8217;ve called it MoveApproval Columns.xml. For more information on the fields attribute follow this link &lt;a href="http://msdn2.microsoft.com/en-us/library/ms437580.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms437580.aspx&lt;/a&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Field&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{53A10CDA-DA2C-4077-B2E8-174B3DD1E5E5}&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MoveApproved&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;DisplayName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Approve the move&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Description&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Allow the document to be moved to the document centre&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Group&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Move Approval&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Text&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Required&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;TRUE&amp;quot;&lt;/span&gt;
         &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Field&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Field&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{C9E51AA2-EB60-4cb7-A83D-B72306B2B72C}&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Document Name&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;DisplayName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Document Name&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Description&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;The name of the document associated with this task&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Group&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Move Approval&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Text&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Required&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;FALSE&amp;quot;&lt;/span&gt;
         &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Field&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Field&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{2961F19C-50B1-423d-ABD9-807B70BE70F1}&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Document URL&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;DisplayName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Document URL&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Description&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;The URL to the document associated with this task&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Group&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Move Approval&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Text&amp;quot;&lt;/span&gt;
         &lt;span class="attr"&gt;Required&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;FALSE&amp;quot;&lt;/span&gt;
         &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Field&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }

&lt;p align="right"&gt;Figure 12 - Columns XML file&lt;/p&gt;

&lt;p&gt;Next let&amp;#8217;s move on to our content type file, firstly we need to give the content type a unique ID, rather than a simple GUID this is actually made up of both a GUID and a prefix that indicated the parent content type , followed by &amp;#8216;00&amp;#8217; and then a GUID. You will see from our example (below) that we are inheriting from &amp;#8216;0x010801&amp;#8217; which is the ID for the workflow task content type (&lt;a href="http://msdn2.microsoft.com/en-us/library/ms452896.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms452896.aspx&lt;/a&gt;). We then simple list the fields that are contained in our content type, you can copy paste and delete unnecessary information (display name, description...) from the columns file. Finally we specify the forms we want to display when a user creates a new, edits an existing or simply displays an item of this content type. For our simple example we will show the same form for all options &amp;#8211; the form we created earlier.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ContentType&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;0x010801003B32C00B8FDB4e9aB99CD9C0D46B9CDA&amp;quot;&lt;/span&gt;
      &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Move Document Approval Content Type&amp;quot;&lt;/span&gt;
      &lt;span class="attr"&gt;Group&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Move Document&amp;quot;&lt;/span&gt;
      &lt;span class="attr"&gt;Description&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Task to approve the movement of a document into the document centre&amp;quot;&lt;/span&gt;
      &lt;span class="attr"&gt;Version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;
      &lt;span class="attr"&gt;Hidden&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;FALSE&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FieldRefs&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FieldRef&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{53A10CDA-DA2C-4077-B2E8-174B3DD1E5E5}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot; MoveApproved &amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FieldRef&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{C9E51AA2-EB60-4cb7-A83D-B72306B2B72C}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Document Name&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FieldRef&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{2961F19C-50B1-423d-ABD9-807B70BE70F1}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Document URL&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;FieldRefs&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;XmlDocuments&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;XmlDocument&lt;/span&gt; &lt;span class="attr"&gt;NamespaceURI&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FormUrls&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;New&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;_layouts/DocumentMoveApproval/DocumentApprovalTask.aspx&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;New&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Display&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;_layouts/DocumentMoveApproval/DocumentApprovalTask.aspx&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Display&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Edit&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;_layouts/DocumentMoveApproval/DocumentApprovalTask.aspx&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Edit&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;FormUrls&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;XmlDocument&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;XmlDocuments&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ContentType&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
  
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/blockquote&gt;

&lt;p align="right"&gt;Figure 13 - Content type XML file&lt;/p&gt;

&lt;p&gt;Finally, the feature file, again it&amp;#8217;s pretty simple. This file specifies a unique ID (a normal GUID this time) for the feature, the location of the other files that are needed (columns and content type files). Also, the property &amp;#8216;GloballyAvailable&amp;#8217; that whilst for our little example isn&amp;#8217;t really needed specifies that the feature will be available everywhere in the portal.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Feature&lt;/span&gt;  &lt;span class="attr"&gt;Id&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;13EA2AAA-29A1-4ed2-AA6F-0B17DB862BA1&amp;quot;&lt;/span&gt;
          &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;File Move and Shortcut Feature&amp;quot;&lt;/span&gt;
          &lt;span class="attr"&gt;Description&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Provides a task item content type to request approval before moving a document to the document centre&amp;quot;&lt;/span&gt;
          &lt;span class="attr"&gt;Version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;12.0.0.0&amp;quot;&lt;/span&gt;
          &lt;span class="attr"&gt;Scope&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Site&amp;quot;&lt;/span&gt;
          &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ElementManifests&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ElementManifest&lt;/span&gt; &lt;span class="attr"&gt;Location&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MoveApproval Columns.xml&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ElementManifest&lt;/span&gt; &lt;span class="attr"&gt;Location&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MoveApproval Content Type.xml&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ElementManifests&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Properties&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Property&lt;/span&gt; &lt;span class="attr"&gt;Key&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;GloballyAvailable&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Properties&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Feature&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
  
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/blockquote&gt;

&lt;p align="right"&gt;Figure 14 - Feature XML file&lt;/p&gt;

&lt;p&gt;These files now need copying over to a directory within the features directory [C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\TEMPLATE\FEATURES] and installing. I called my directory &amp;#8216;MoveApprovalTaskContentType&amp;#8217; so my install script is as follows.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\BIN&amp;gt;stsadm -o installfeature -name MoveApprovalTaskContentType&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\BIN&amp;gt;stsadm -o activatefeature -name MoveApprovalTaskContentType -url http:&lt;span class="rem"&gt;//localhost&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
  
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/blockquote&gt;

&lt;p align="right"&gt;Figure 15 - Install the content type&lt;/p&gt;

&lt;p&gt;Now is a good time to point out that in actual fact, for our example the fields we specify in the content type are actually not so important. When we pass data back to our workflow from the ASPX page we are actually just creating a hash table object and the truth is that we can put any data we like in there and it will be passed to the workflow regardless of the content type specification. However there are myriad reasons why it&amp;#8217;s a good idea to keep the content type and parameter passing between ASPX page and workflow in synch, not least that the user may want to use your content type as the basis (parent) for another task content type. You can now check that the content type has been deployed by looking at the site setting of your site and selecting Site Content Type Gallery, from here you will see your content type and can check the field definitions.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image016.gif"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="150" alt="clip_image016" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image016_thumb.gif" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="right"&gt;Figure 16 - Deployed content type&lt;/p&gt;

&lt;p&gt;The final piece in the puzzle is to marry the content type up with the workflow. This is relatively straightforward. Firstly we need to adapt our workflow to create the task. Since this task uses a custom content type, we&amp;#8217;ll need to add a &amp;#8216;CreateTaskWithContentType&amp;#8217; activity to our workflow. Drag this from the toolbar into the relevant place in the workflow and: &lt;/p&gt;

&lt;p&gt;1. Paste the content type GUID you used in the content type XML file into the ContentTypeId property&lt;/p&gt;

&lt;p&gt;2. Type a unique name into the correlation token property and set the owneractivityname to the preceeding activity&lt;/p&gt;

&lt;p&gt;3. Click the ellipses on the TaskId property and click Bind to new member, select Field and either accept the default name or name it as you wish&lt;/p&gt;

&lt;p&gt;4. Click the ellipses next to the TaskProperties property and bind this to a new field&lt;/p&gt;

&lt;p&gt;5. Switch to the event view in the properties window (the &lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image018.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="22" alt="clip_image018" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image018_thumb.jpg" width="19" border="0" /&gt;&lt;/a&gt; icon), and double click the MethodInvoking property, use the code that follows this description to create a new GUID for the task.&lt;/p&gt;

&lt;p&gt;&lt;i&gt;Figure 17 &lt;/i&gt;shows the final state of the properties window for my create task step.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image020.gif"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="177" alt="clip_image020" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image020_thumb.gif" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="right"&gt;Figure 17 - Create task properties&lt;/p&gt;

&lt;p&gt;Now that we&amp;#8217;ve created a task we need to wait for the user to update and complete the task before we continue our workflow processing.&lt;/p&gt;

&lt;p&gt;1. Add a while loop below the activity you just created &lt;/p&gt;

&lt;p&gt;2. Within the while block add an &amp;#8216;OnTaskChanged&amp;#8217; activity, name it taskChanged.&lt;/p&gt;

&lt;p&gt;3. Click on the while loop activity and set the property &amp;#8216;Condition&amp;#8217; to a code condition, expand the condition property and click the bind icon (&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image022.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="16" alt="clip_image022" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image022_thumb.jpg" width="16" border="0" /&gt;&lt;/a&gt;), bind to a new property member.&lt;/p&gt;

&lt;p&gt;4. Click on the taskChanged activity and set the correlation token to the same as you created for the create task.&lt;/p&gt;

&lt;p&gt;5. Click the ellipses next to the AfterProperties property and bind to a new field&lt;/p&gt;

&lt;p&gt;6. Click the ellipses next to TaskId and bind to the existing field you created in thecreate task activity&lt;/p&gt;

&lt;p&gt;7. Switch to the event view in the properties window (the &lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image0181.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="22" alt="clip_image018[1]" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image0181_thumb.jpg" width="19" border="0" /&gt;&lt;/a&gt; icon), and double click the MethodInvoking property, use the code that follows this description to check for completion and process the data.&lt;/p&gt;

&lt;p&gt;&lt;i&gt;Figure 18 &lt;/i&gt;shows the final state of the properties window for my task changed step.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image024.gif"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="160" alt="clip_image024" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image024_thumb.gif" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="right"&gt;Figure 18 - Task changed properties&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s it for the workflow, you can cross check your code against the code I&amp;#8217;ve used in &lt;i&gt;figure 19 &lt;/i&gt;and you should then be ready to roll.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.ComponentModel.Design;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Drawing;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Workflow.ComponentModel.Compiler;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Workflow.ComponentModel.Serialization;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Workflow.ComponentModel;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Workflow.ComponentModel.Design;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Workflow.Runtime;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Workflow.Activities;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Workflow.Activities.Rules;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.SharePoint;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.SharePoint.Workflow;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.SharePoint.WorkflowActions;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.Office.Workflow.Utility;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Specialized;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xml.Serialization;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xml;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; DocumentMoveAndShortcut&lt;/pre&gt;

    &lt;pre class="alt"&gt;{&lt;/pre&gt;

    &lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// This class along with associated forms and content type definitions&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;    &lt;span class="rem"&gt;/// demonstrates the creation of a simple workflow and passing of data &lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// from infopath forms and ASPX forms&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;sealed&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MoveAndMark : SequentialWorkflowActivity&lt;/pre&gt;

    &lt;pre&gt;    {&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// Holds the description of the history log entry&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; _historyDesc;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// Holds the outcome (success, failure...) of the history log entry&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; _historyOutcome;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// The URL to the document centre library i.e. http://localhost/Docs/Documents/&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; _documentCentre = &lt;span class="str"&gt;&amp;quot;http://moss2007win2008/Docs/Documents/&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// The name of the list to hold gravestone entries for moved files&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; _listName = &lt;span class="str"&gt;&amp;quot;Promoted Files&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// A Person object representing the specified approved.  Specified on association&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Person _approver  = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// Flag to depict whether gravestones are left behind for moved files&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; _addGraveStone = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// Flag to indicate task completion&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; _taskComplete;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// Flag to indicate that the file move has been approved&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; _moveApproved;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// GUID of the workflow created task&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Guid moveApprovalTask_TaskId1 = &lt;span class="kwrd"&gt;default&lt;/span&gt;(System.Guid);&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// GUID of this instance of the workflow&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Guid workflowId = &lt;span class="kwrd"&gt;default&lt;/span&gt;(System.Guid);&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// A handle to the workflow properties&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; SPWorkflowActivationProperties workflowProperties = &lt;span class="kwrd"&gt;new&lt;/span&gt; SPWorkflowActivationProperties();&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// The properties of the workflow created task&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; SPWorkflowTaskProperties moveApprovalTask_TaskProperties1 = &lt;span class="kwrd"&gt;new&lt;/span&gt; Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// The properties of the workflow created task after the task has been changed&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; SPWorkflowTaskProperties taskChanged_AfterProperties1 = &lt;span class="kwrd"&gt;new&lt;/span&gt; Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// Default constructor&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; MoveAndMark()&lt;/pre&gt;

    &lt;pre class="alt"&gt;        {&lt;/pre&gt;

    &lt;pre&gt;            InitializeComponent();&lt;/pre&gt;

    &lt;pre class="alt"&gt;        }&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Called when the workflow is activated&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;sender&amp;quot;&amp;gt;Event originator&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;e&amp;quot;&amp;gt;Arguments&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; WorkflowActivation_Invoked(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, ExternalDataEventArgs e)&lt;/pre&gt;

    &lt;pre&gt;        {&lt;/pre&gt;

    &lt;pre class="alt"&gt;            workflowId = workflowProperties.WorkflowId;&lt;/pre&gt;

    &lt;pre&gt;        }&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// Retrieves the workflow properties needed for processing&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; getInstantiationData()&lt;/pre&gt;

    &lt;pre class="alt"&gt;        {&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;            {&lt;/pre&gt;

    &lt;pre&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (workflowProperties.InitiationData!=&lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre class="alt"&gt;                {&lt;/pre&gt;

    &lt;pre&gt;                    XmlSerializer serialiser = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(associationFields));&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    XmlTextReader reader = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextReader(&lt;span class="kwrd"&gt;new&lt;/span&gt; System.IO.StringReader(workflowProperties.InitiationData));&lt;/pre&gt;

    &lt;pre&gt;                    associationFields initData = (associationFields)serialiser.Deserialize(reader);&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    _approver = initData.contact[0];&lt;/pre&gt;

    &lt;pre&gt;                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (initData.gravestoneSpecified)&lt;/pre&gt;

    &lt;pre class="alt"&gt;                        _addGraveStone = (&lt;span class="kwrd"&gt;bool&lt;/span&gt;)initData.gravestone;&lt;/pre&gt;

    &lt;pre&gt;                }&lt;/pre&gt;

    &lt;pre class="alt"&gt;            }&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception) { }&lt;/pre&gt;

    &lt;pre class="alt"&gt;        }&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Returns a boolean in the ConditionalEventArgs argument to specify whether the document has been marked as ready to be moved&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;sender&amp;quot;&amp;gt;The originating object&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;e&amp;quot;&amp;gt;input / output paramenters&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; IsDocumentReadyForMove(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, ConditionalEventArgs e)&lt;/pre&gt;

    &lt;pre&gt;        {&lt;/pre&gt;

    &lt;pre class="alt"&gt;            e.Result = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;            {&lt;/pre&gt;

    &lt;pre&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (workflowProperties.Item != &lt;span class="kwrd"&gt;null&lt;/span&gt; &amp;amp;&amp;amp;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    workflowProperties.Item[&lt;span class="str"&gt;&amp;quot;Approved for move&amp;quot;&lt;/span&gt;] != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre&gt;                {&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    e.Result = (&lt;span class="kwrd"&gt;bool&lt;/span&gt;)workflowProperties.Item[&lt;span class="str"&gt;&amp;quot;Approved for move&amp;quot;&lt;/span&gt;];&lt;/pre&gt;

    &lt;pre&gt;                }&lt;/pre&gt;

    &lt;pre class="alt"&gt;            }&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception) { }&lt;/pre&gt;

    &lt;pre class="alt"&gt;        }&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Called when the document is ready and has been approved for moving.  Document will be moved without leaving a gravestone marker.&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;sender&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;e&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MoveDocument_ExecuteCode(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;

    &lt;pre&gt;        {&lt;/pre&gt;

    &lt;pre class="alt"&gt;            MoveAndLeaveMarker(&lt;span class="kwrd"&gt;false&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre&gt;        }&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// Called when the document is ready and has been approved for moving.  Document will be moved and a gravestone marker left behind.&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;sender&amp;quot;&amp;gt;The originating object&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;e&amp;quot;&amp;gt;input / output paramenters&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MoveDocumentAndMark_ExecuteCode(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;

    &lt;pre class="alt"&gt;        {&lt;/pre&gt;

    &lt;pre&gt;            MoveAndLeaveMarker(&lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre class="alt"&gt;        }&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// This will move the file and if appropriate leave behind a gravestone to mark its original location&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;mark&amp;quot;&amp;gt;Flag to indicate whether a gravestone should be left behind after move&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MoveAndLeaveMarker(&lt;span class="kwrd"&gt;bool&lt;/span&gt; mark)&lt;/pre&gt;

    &lt;pre class="alt"&gt;        {&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;            {&lt;/pre&gt;

    &lt;pre&gt;                &lt;span class="kwrd"&gt;string&lt;/span&gt; filename = _documentCentre + workflowProperties.Item.File.Name;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                workflowProperties.Item.CopyTo(filename);&lt;/pre&gt;

    &lt;pre&gt;                _historyDesc = &lt;span class="str"&gt;&amp;quot;Moved document &amp;quot;&lt;/span&gt; + workflowProperties.Item.File.Name + &lt;span class="str"&gt;&amp;quot; from the library &amp;quot;&lt;/span&gt; +&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    workflowProperties.List.Title + &lt;span class="str"&gt;&amp;quot; in the site &amp;quot;&lt;/span&gt; + workflowProperties.Web.Title + &lt;span class="str"&gt;&amp;quot; (&amp;quot;&lt;/span&gt; +&lt;/pre&gt;

    &lt;pre&gt;                    workflowProperties.Web.Url + &lt;span class="str"&gt;&amp;quot;) to the document centre&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                _historyOutcome = &lt;span class="str"&gt;&amp;quot;Success&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (mark)&lt;/pre&gt;

    &lt;pre&gt;                {&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    &lt;span class="rem"&gt;//leave a grave stone to show that the file has been moved&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;                    SPList list = workflowProperties.Web.Lists[_listName];&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (list == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre&gt;                    {&lt;/pre&gt;

    &lt;pre class="alt"&gt;                        &lt;span class="rem"&gt;//add the list if it doesn&amp;#39;t exist&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;                        workflowProperties.Web.Lists.Add(_listName, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, SPListTemplateType.GenericList);&lt;/pre&gt;

    &lt;pre class="alt"&gt;                        workflowProperties.Web.Update();&lt;/pre&gt;

    &lt;pre&gt;                        list = workflowProperties.Web.Lists[_listName];&lt;/pre&gt;

    &lt;pre class="alt"&gt;                        list.Fields.Add(&lt;span class="str"&gt;&amp;quot;Comments&amp;quot;&lt;/span&gt;, SPFieldType.Text, &lt;span class="kwrd"&gt;false&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre&gt;                        list.Fields.Add(&lt;span class="str"&gt;&amp;quot;Link&amp;quot;&lt;/span&gt;, SPFieldType.URL, &lt;span class="kwrd"&gt;false&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre class="alt"&gt;                        StringCollection sCol = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringCollection();&lt;/pre&gt;

    &lt;pre&gt;                        sCol.Add(&lt;span class="str"&gt;&amp;quot;Title&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre class="alt"&gt;                        sCol.Add(&lt;span class="str"&gt;&amp;quot;Comments&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre&gt;                        sCol.Add(&lt;span class="str"&gt;&amp;quot;Link&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre class="alt"&gt;                        list.Views.Add(_listName + &lt;span class="str"&gt;&amp;quot;Default View&amp;quot;&lt;/span&gt;, sCol, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, 100, &lt;span class="kwrd"&gt;true&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre&gt;                        list.Update();&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    }&lt;/pre&gt;

    &lt;pre&gt;                    &lt;span class="rem"&gt;//add and item to the list&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    SPListItem item = list.Items.Add();&lt;/pre&gt;

    &lt;pre&gt;                    item[&lt;span class="str"&gt;&amp;quot;Title&amp;quot;&lt;/span&gt;] = workflowProperties.Item.File.Name;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    item[&lt;span class="str"&gt;&amp;quot;Comments&amp;quot;&lt;/span&gt;] = _historyDesc;&lt;/pre&gt;

    &lt;pre&gt;                    item[&lt;span class="str"&gt;&amp;quot;Link&amp;quot;&lt;/span&gt;] = filename;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    item.Update();&lt;/pre&gt;

    &lt;pre&gt;                }&lt;/pre&gt;

    &lt;pre class="alt"&gt;                &lt;span class="rem"&gt;//delete the old file to complete the move&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;                workflowProperties.Item.Delete();&lt;/pre&gt;

    &lt;pre class="alt"&gt;            }&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception ex)&lt;/pre&gt;

    &lt;pre class="alt"&gt;            {&lt;/pre&gt;

    &lt;pre&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (workflowProperties.Item != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    _historyDesc = &lt;span class="str"&gt;&amp;quot;Failed to move document &amp;quot;&lt;/span&gt; + workflowProperties.Item.File.Name + &lt;span class="str"&gt;&amp;quot;. Error: &amp;quot;&lt;/span&gt; + ex.Message;&lt;/pre&gt;

    &lt;pre&gt;                &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    _historyDesc = &lt;span class="str"&gt;&amp;quot;Failed to move document. Error: &amp;quot;&lt;/span&gt; + ex.Message;&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                _historyOutcome = &lt;span class="str"&gt;&amp;quot;Failure&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;            }&lt;/pre&gt;

    &lt;pre class="alt"&gt;        }&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Gets data from the instantiation form and sets the gravestone flag&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;sender&amp;quot;&amp;gt;The originating object&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;e&amp;quot;&amp;gt;input / output paramenters&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; markMove(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, ConditionalEventArgs e)&lt;/pre&gt;

    &lt;pre&gt;        {&lt;/pre&gt;

    &lt;pre class="alt"&gt;            getInstantiationData();&lt;/pre&gt;

    &lt;pre&gt;            e.Result = _addGraveStone;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        }&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Sets up the task list and creates a task for approving the document move&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;sender&amp;quot;&amp;gt;The originating object&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;e&amp;quot;&amp;gt;input / output paramenters&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; moveApprovalTask_MethodInvoking(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;

    &lt;pre&gt;        {&lt;/pre&gt;

    &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;this&lt;/span&gt;.moveApprovalTask_TaskId1 = Guid.NewGuid();&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;.workflowProperties.TaskList.ContentTypesEnabled != &lt;span class="kwrd"&gt;true&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre class="alt"&gt;                workflowProperties.TaskList.ContentTypesEnabled = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;            SPContentTypeId ctMoveID = &lt;span class="kwrd"&gt;new&lt;/span&gt; SPContentTypeId(moveApprovalTask.ContentTypeId);&lt;/pre&gt;

    &lt;pre class="alt"&gt;            SPContentType ctMove = workflowProperties.Site.RootWeb.ContentTypes[ctMoveID];&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;bool&lt;/span&gt; contentTypeExists = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (SPContentType contentType &lt;span class="kwrd"&gt;in&lt;/span&gt; workflowProperties.TaskList.ContentTypes)&lt;/pre&gt;

    &lt;pre&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (contentType.Name == ctMove.Name)&lt;/pre&gt;

    &lt;pre class="alt"&gt;                {&lt;/pre&gt;

    &lt;pre&gt;                    contentTypeExists = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;                }&lt;/pre&gt;

    &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (contentTypeExists != &lt;span class="kwrd"&gt;true&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre&gt;                workflowProperties.TaskList.ContentTypes.Add(ctMove);&lt;/pre&gt;

    &lt;pre class="alt"&gt;            getInstantiationData();&lt;/pre&gt;

    &lt;pre&gt;            moveApprovalTask_TaskProperties1.Title = &lt;span class="str"&gt;&amp;quot;Request approval for document move (promotion)&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;            moveApprovalTask_TaskProperties1.DueDate = DateTime.Now.AddDays(1);&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;._approver != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre class="alt"&gt;                moveApprovalTask_TaskProperties1.AssignedTo = &lt;span class="kwrd"&gt;this&lt;/span&gt;._approver.AccountId.ToString();&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                moveApprovalTask_TaskProperties1.AssignedTo = workflowProperties.OriginatorUser.LoginName;&lt;/pre&gt;

    &lt;pre&gt;            moveApprovalTask_TaskProperties1.PercentComplete = 0F;&lt;/pre&gt;

    &lt;pre class="alt"&gt;            moveApprovalTask_TaskProperties1.ExtendedProperties[&lt;span class="str"&gt;&amp;quot;Document Name&amp;quot;&lt;/span&gt;] = workflowProperties.Item.File.Name;&lt;/pre&gt;

    &lt;pre&gt;            moveApprovalTask_TaskProperties1.ExtendedProperties[&lt;span class="str"&gt;&amp;quot;Document URL&amp;quot;&lt;/span&gt;] = workflowProperties.Web.Url + &lt;span class="str"&gt;&amp;quot;/&amp;quot;&lt;/span&gt; + workflowProperties.Item.File.Url;&lt;/pre&gt;

    &lt;pre class="alt"&gt;            moveApprovalTask_TaskProperties1.ExtendedProperties[&lt;span class="str"&gt;&amp;quot;Approved&amp;quot;&lt;/span&gt;] = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;        }&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// Called when the task item has been changed, checks for completion and approval status&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;sender&amp;quot;&amp;gt;The originating object&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;e&amp;quot;&amp;gt;input / output paramenters&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; taskChanged_Invoked(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, ExternalDataEventArgs e)&lt;/pre&gt;

    &lt;pre class="alt"&gt;        {&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (taskChanged_AfterProperties1.PercentComplete == 1F)&lt;/pre&gt;

    &lt;pre class="alt"&gt;            {&lt;/pre&gt;

    &lt;pre&gt;                &lt;span class="kwrd"&gt;this&lt;/span&gt;._taskComplete = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;this&lt;/span&gt;._moveApproved = taskChanged_AfterProperties1.ExtendedProperties[&lt;span class="str"&gt;&amp;quot;MoveApproved&amp;quot;&lt;/span&gt;].ToString()==&lt;span class="str"&gt;&amp;quot;True&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;            }&lt;/pre&gt;

    &lt;pre class="alt"&gt;        }&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Checks and returns via the ConditionalEventArgs parameter whether the task has been completed&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;sender&amp;quot;&amp;gt;The originating object&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;e&amp;quot;&amp;gt;input / output paramenters&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; isTaskComplete(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, ConditionalEventArgs e)&lt;/pre&gt;

    &lt;pre&gt;        {&lt;/pre&gt;

    &lt;pre class="alt"&gt;            e.Result = !&lt;span class="kwrd"&gt;this&lt;/span&gt;._taskComplete;&lt;/pre&gt;

    &lt;pre&gt;        }&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// Checks and returns via the ConditionalEventArgs parameter whether the move has been approved&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;sender&amp;quot;&amp;gt;The originating object&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;e&amp;quot;&amp;gt;input / output paramenters&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; isMoveApproved(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, ConditionalEventArgs e)&lt;/pre&gt;

    &lt;pre class="alt"&gt;        {&lt;/pre&gt;

    &lt;pre&gt;            e.Result = &lt;span class="kwrd"&gt;this&lt;/span&gt;._moveApproved;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        }&lt;/pre&gt;

    &lt;pre&gt;    }&lt;/pre&gt;

    &lt;pre class="alt"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
  
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/blockquote&gt;

&lt;p align="right"&gt;Figure 19 - Workflow code&lt;/p&gt;

&lt;p&gt;For completeness the following figure shows the final state of my workflow.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image002.gif"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="244" alt="clip_image002" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image002_thumb.gif" width="215" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="right"&gt;Figure 20 - Final workflow design&lt;/p&gt;

&lt;p&gt;To test the workflow, run your workflow project, this will deploy it into the SharePoint library and open up an explorer window, edit a document and mark it ready for move. This should spark up your workflow and create a task, edit the task and complete it. You should see that your workflow has run through. If there are errors you can take a look at the workflow status screen by clicking the link in the document library and if you need to debug any further you can open the latest log file from the logs directory and search for &amp;#8216;workflow&amp;#8217;. With a small amount of configuration in the SharePoint GUI this is what my home page looks like with the documents and a list of moved (promoted) documents displayed together:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image0044.gif"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="133" alt="clip_image004[4]" src="http://www.clearchaos.net/AndysBlogImages/CollectingdataincustomSharePointworkflow_BDB0/clip_image0044_thumb.gif" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="right"&gt;Figure 21 - Final result&lt;/p&gt;

&lt;p align="left"&gt;PHEW - ALL DONE!&lt;/p&gt;

&lt;p align="right"&gt;&lt;/p&gt;Content by : Andrew Noon
			&lt;hr&gt;&lt;span style="font-size:10pt;"&gt;Posted on &lt;a href="http://www.sharepointblogs.com/"&gt;SharePoint Blogs&lt;/a&gt;&lt;/span&gt;
		  &lt;img src="http://www.sharepointblogs.com/aggbug.aspx?PostID=12545" width="1" height="1"&gt;</description></item><item><title>SharePoint 2007 workflow with Visual Studio 2008</title><link>http://www.sharepointblogs.com/andynoon/archive/2008/02/06/sharepoint-2007-workflow-with-visual-studio-2008.aspx</link><pubDate>Wed, 06 Feb 2008 17:12:00 GMT</pubDate><guid isPermaLink="false">1f6a1193-f4bb-4480-a5ae-b538d8b20f46:12377</guid><dc:creator>Andrew Noon</dc:creator><slash:comments>47</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.sharepointblogs.com/andynoon/rsscomments.aspx?PostID=12377</wfw:commentRss><comments>http://www.sharepointblogs.com/andynoon/archive/2008/02/06/sharepoint-2007-workflow-with-visual-studio-2008.aspx#comments</comments><description>&lt;p&gt;&lt;a class="" title="OLE_LINK4" name="OLE_LINK4"&gt;&lt;/a&gt;&lt;a class="" title="OLE_LINK3" name="OLE_LINK3"&gt;&lt;/a&gt;Before getting into this I thought developing workflow for SharePoint 2007 was a complex and daunting task to undertake. Whilst you still won’t find me saying it’s easy I will say that I’ve been pleasantly surprised at how intuitive the process has been. The following pages demonstrate the steps that are required to get a simple workflow going from setup to development and deployment.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Installation prerequisites &lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Visual Studio 2008 greatly simplified the processes of creating, deploying and even debugging workflows but if you need to it is possible to do all of this with Visual Studio 2005 and some additional work. The remainder of this document shows the steps required to create a simple workflow using the 2008 version of the product, so bear in mind that not everything will work as easily if you choose to use an older version such as 2005.&lt;/p&gt;
&lt;h5&gt;Visual Studio 2008&lt;/h5&gt;
&lt;p&gt;&lt;b&gt;Software&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Link for more information&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Visual Studio 2008 &lt;/p&gt;
&lt;p&gt;&lt;a href="http://msdn2.microsoft.com/en-gb/vstudio/default.aspx"&gt;MSDN Visual Studio Site&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Windows SharePoint Services (WSS)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://office.microsoft.com/en-us/sharepointtechnology/FX100503841033.aspx"&gt;WSS 3.0 on Microsoft.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Microsoft Office SharePoint Server (MOSS)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/sharepoint/default.mspx"&gt;MOSS 2007 on Microsoft.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;WSS Software Development Kit (optional)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=05E0DD12-8394-402B-8936-A07FE8AFAFFD&amp;amp;displaylang=en"&gt;SDK Download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;MOSS Software Development Kit (optional)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=6d94e307-67d9-41ac-b2d6-0074d6286fa9&amp;amp;displaylang=en"&gt;SDK Download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Table 1 - Visual Studio 2008 components&lt;/p&gt;
&lt;h5&gt;Visual Studio 2005&lt;/h5&gt;
&lt;p&gt;&lt;b&gt;Software&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Link for more information&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Visual Studio 2005 Professional or Team Suite&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msdn2.microsoft.com/en-us/ie/bb188238.aspx"&gt;MSDN Visual Studio Site&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For Team Suite make sure you also download the latest Service Pack (SP1 at time of print)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC"&gt;Service Pack 1 Download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;.Net 3.0 (FX) Runtime&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=10CC340B-F857-4A14-83F5-25634C3BF043"&gt;.Net 3.0 Download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Windows SharePoint Services (WSS)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://office.microsoft.com/en-us/sharepointtechnology/FX100503841033.aspx"&gt;WSS 3.0 on Microsoft.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Visual Studio extensions for workflow&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=5D61409E-1FA3-48CF-8023-E8F38E709BA6&amp;amp;displaylang=en"&gt;Download workflow extensions&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Visual Studio extensions for WSS&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=19F21E5E-B715-4F0C-B959-8C6DCBDC1057&amp;amp;displaylang=en"&gt;Download WSS extensions&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Microsoft Office SharePoint Server (MOSS)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/sharepoint/default.mspx"&gt;MOSS 2007 on Microsoft.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;WSS Software Development Kit (optional)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=05E0DD12-8394-402B-8936-A07FE8AFAFFD&amp;amp;displaylang=en"&gt;SDK Download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;MOSS Software Development Kit (optional)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=6d94e307-67d9-41ac-b2d6-0074d6286fa9&amp;amp;displaylang=en"&gt;SDK Download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Table 2 - Visual Studio 2005 components&lt;/p&gt;
&lt;h4&gt;So what is a WSS workflow?&lt;/h4&gt;
&lt;p&gt;Firstly, it is assumed that you have a basic understanding of both workflow principles and development. Specifically though, when we talk about Windows SharePoint Services (WSS) and workflow we are talking about controlling events that can occur when an item in a list or library in a WSS site is changed. Typically this is either to model a business process through a level of automation (Business Process Engineering) and therefore minimising or to manage the lifecycle of content (Information Lifecycle Management).&lt;/p&gt;
&lt;p&gt;Windows Workflow Foundation (WF) is the basic underlying technology that is used to define a workflow however WF alone does not make a workflow happen, it needs a host. WSS forms the host service that runs the workflow in conjunction with the WF run time. Together they will manage tasks, assignment of tasks, persist state over long running transactions (human intervention, scheduled tasks...), scheduling and tracking.&lt;/p&gt;
&lt;h4&gt;Sequential Vs State workflows, what is the difference?&lt;/h4&gt;
&lt;p&gt;Sequential workflow is nothing like it sounds. It does not mean that there is a single thread of activity with fixed route from start to end. A sequential workflow can have parallel tasks, can branch depending on state, properties, user response...In this case sequential simple means that the workflow has a single start point follows through a number of steps to reach a goal.&lt;/p&gt;
&lt;p&gt;State (machine) workflows basically mean a workflow whereby the core component (a task, a document...) can have a number of states (draft, for review, reviewed, released, approved) and the movement between each of those states is controlled, for example it may be inappropriate to move state between draft and approved without passing the other state first. State workflow has a start and a number of activities that govern state but do not necessarily have to have an end state i.e. Approval can be the best state for content but after approval it’s entirely possible that the content may be reverted to draft for update.&lt;/p&gt;
&lt;h4&gt;Basic environment setup&lt;/h4&gt;
&lt;p&gt;You should now be able to load Visual Studio and within the workflow section of the new projects library you should have the option to create a number of different workflow types.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/SharePoint2007workflowwithVisualStudio20_ECAB/clip_image002.jpg"&gt;&lt;img style="BORDER-TOP-WIDTH:0px;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" height="167" alt="clip_image002" src="http://www.clearchaos.net/AndysBlogImages/SharePoint2007workflowwithVisualStudio20_ECAB/clip_image002_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Figure 1- Setting the project name&lt;/p&gt;
&lt;p&gt;At this point it depends on whether you are working on a MOSS2007 server or not as to what you do next. If you’re on a MOSS2007 server then simply create a new Sequential Workflow project. If not you’ll need to grab the SharePoint DLLs from the server, the easiest way of doing this is to take microsoft.sharepoint.* and microsoft.office * from the servers C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\ISAPI directory and create and copy to the same path on your development machine. You will now have all the references you need to create a workflow project, go ahead and simply create a new Sequential Workflow project.&lt;/p&gt;
&lt;p&gt;You will be asked to specify both the name of the workflow to display to users and also the initial library you want to use during development (for debugging the workflow). Note that in Visual Studio 2005 you do not get this prompt and need to manually set this up.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/SharePoint2007workflowwithVisualStudio20_ECAB/clip_image004.jpg"&gt;&lt;img style="BORDER-TOP-WIDTH:0px;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" height="193" alt="clip_image004" src="http://www.clearchaos.net/AndysBlogImages/SharePoint2007workflowwithVisualStudio20_ECAB/clip_image004_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Figure 2 - Naming the workflow&lt;/p&gt;
&lt;p&gt;You will now be asked for the library to attach the development workflow to, the workflow history list (tracks progress) and the task list that you want to use (if assigning tasks).&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.clearchaos.net/AndysBlogImages/SharePoint2007workflowwithVisualStudio20_ECAB/clip_image006.jpg"&gt;&lt;img style="BORDER-TOP-WIDTH:0px;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" height="194" alt="clip_image006" src="http://www.clearchaos.net/AndysBlogImages/SharePoint2007workflowwithVisualStudio20_ECAB/clip_image006_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Figure 3 - Set workflow associations&lt;/p&gt;
&lt;p&gt;You will then need to decide when you want your workflow to fire, there are three events that can cause a workflow to start.&lt;/p&gt;
&lt;p&gt;· Manually i.e. the user chooses to start a workflow on the current item&lt;/p&gt;
&lt;p&gt;· On creation, the workflow is started as soon as an item is created (this can be either saving a document to a library or list, uploading a document or simply creating a new item)&lt;/p&gt;
&lt;p&gt;· On change, the workflow will fire every time an item is changed, for document this means that the workflow will start if either the document itself is changed or any of the metadata associated with the document is changed.&lt;/p&gt;
&lt;p&gt;I’m selecting all three because I want a user to be able to choose when 