<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Latest Articles by furuknap</title>
<link>http://www.articletrader.com/</link>
<description>Articles at ArticleTrader</description>
<language>en-us</language>
<item>
<title>SharePoint Designer Workflow in a Nutshell</title>
<link>http://www.articletrader.com/computers/sharepoint-designer-workflow-in-a-nutshell.html</link>
<guid>http://www.articletrader.com/computers/sharepoint-designer-workflow-in-a-nutshell.html</guid>
<pubDate>Sun, 31 May 2009 18:28:14 -0500</pubDate>
<description><![CDATA[ (Article originally posted on <a href="http://furuknap.blogspot.com/2009/06/sharepoint-designer-workflow-in.html">http://furuknap.blogspot.com/2009/06/sharepoint-designer-workflow-in.html</a>)<br /><br /><b>So, What Is a Workflow Anyway? </b><br />Workflows are just what their name implies, flows of work. Think of any process where some set of actions are performed, such as buying an item in a store, taking a shower, filing a letter, or even dating someone special. All of these tasks are composed of tasks or states where some action or event is expected. <br /><br />Let's take a look at one of them, buying an item in a store. <br /><br />When you buy an item, you need to do the following:<br /><br />1. Find the correct item. <br />2. Take the item to the counter. <br />3. Receive the price from the attendant. <br />4. Decide between using cash or using a credit card.<br /><br /><i>If using cash: </i><br />5a.1 Give appropriate amount to the attendant. <br />5a.2 Receive any change. <br />5a.3 Verify change. <br />5a.4 Pocket change.<br /><br /><i>If using a credit card: </i><br />5b.1 Give credit card to the attendant. <br />5b.2 Receive receipt for signature. <br />5b.3 Verify amount. <br />5b.4 Sign receipt. <br />5b.5 Return receipt to the attendant.<br /><br />6. Put pen in pocket. <br />7. Retrieve item, and run before the attendant notices the missing pen.<br /><br />Don't be fooled. This task may seem simple, but that's only because we do it so often it has become routine. Several of these steps require an amount of substeps, and any failure will need to be handled according to some set of rules. <br /><br />A workflow structures such processes into manageable chunks called activities. Each activity performs one or more small operations, such as verifying an amount or stealing a pen, and the workflow makes sure that everything is done in order and handles exceptions to the regular flow.<br /><br /><b>Workflows in SharePoint</b><br />SharePoint integrates tightly with Windows Workflow Foundation, or WF, and workflow is an integral part of SharePoint. <br /><br />By default, the free version of SharePoint, Windows SharePoint Services, include only a single simple workflow, the Three-state workflow. The more advanced, and for-purchase version of SharePoint, Microsoft Office SharePoint Server 2007, include more workflows, such as Approval workflow, Collect Signatures workflow, and Disposition Approval workflow. <br /><br />However, the true power of workflow in SharePoint comes from being able to design specific workflows that can adapt to and support an organization's needs. <br /><br /><b>Businesses Needs Workflow</b><br />Most, if not all, businesses have business specific processes that will benefit from having at least some degree of automation. If nothing else, workflow enables organization to include auditing of business processes. <br /><br />However, most businesses and organizations are also unique. Creating generic workflows that can be applied to many different organizations is difficult and not even desirable, because each organization works in different ways. <br /><br />Not just that, but business processes change. Even if a business invests in custom developed workflow solutions, chances are, those solutions will require massive re-design frequently. Having a workflow solution that allows businesses to adapt their business processes as requirements change will greatly increase organization flexibility.<br /><br /><b>SharePoint Designer Workflow to the Rescue!</b><br />Perhaps the biggest advantage of developing workflows in SharePoint Designer is the ease of development. Most end users can create tailored workflows with just basic training. When business needs change, the same end users can adapt the workflows to support the changing needs. <br /><br />A SharePoint Designer workflow workflow is an easy, cheap, and somewhat limited entry point to workflow development. <br /><br />They're easy, because most end users and administrators can become workflow developers without too much training. <br /><br />They're cheap, because both SPD and SharePoint are now free, and the learning curve is gentle. <br /><br />They're somewhat limited, because, despite workarounds and extensibility, SharePoint Designer workflows are designed for ease of development and lack several of the more powerful options available in other workflow design products.<br /><br />Despite these limitations, however, SharePoint Designer remains a very powerful option for:<br /><br />- Organizations without specialized workflow programmers<br /><br />- Organizations with frequently changing needs<br /><br />- Organizations with limited budgets or high return on investment requirements<br /><br /><b>Where can I Learn SharePoint Designer Workflow </b><br />If you, or your organization, want to explore the powers of SharePoint Designer workflow, you have several options. <br /><br />For online training, EndUserSharePoint.com provides a free 5-part series of <a href="http://www.endusersharepoint.com/?p=1659">SharePoint Designer workflow videos</a>. These videos will introduce you to developing SPD workflows, but also show some advanced features, such as looping and iterative SPD workflows.<br /><br />Understanding SharePoint Journal also has several resources available on the newly launched website <a href="http://www.sharepointdesignerworkflow.com/">http://www.sharepointdesignerworkflow.com/</a>, including Issue 4 of the journal, titled SharePoint Designer Workflow. <br /><br />Besides these options, Microsoft also has several videos and tutorials available at their site. Woody Windischman has also recently released a book, titled Professional Microsoft Office SharePoint Designer 2007 that includes a very good chapter on workflow as well.<br /><br />.b<br /><br /><br />--<br />Bjørn Furuknap is a Senior Developer and Architect, passionate writer, and a SharePointholic. Author of "<a href="http://www.understandingsharepoint.com/userexperience/">Building the SharePoint User Experience"</a> and editor/author for "<a href="http://www.understandingsharepoint.com/journal/">Understanding SharePoint Journal"</a>.<br><br>Source: <a href="http://www.articletrader.com/">http://www.articletrader.com</a> ]]></description>
</item><item>
<title>What are SharePoint Content Types?</title>
<link>http://www.articletrader.com/computers/software/what-are-sharepoint-content-types.html</link>
<guid>http://www.articletrader.com/computers/software/what-are-sharepoint-content-types.html</guid>
<pubDate>Wed, 20 May 2009 11:26:34 -0500</pubDate>
<description><![CDATA[ (Article originally posted on <a href="http://furuknap.blogspot.com/2009/05/what-are-sharepoint-content-types.html">http://furuknap.blogspot.com/2009/05/what-are-sharepoint-content-types.html</a>)<br /><br />When I wrote issue 2 of Understanding SharePoint Journal, I assumed, perhaps wrongly so, that most people were familiar with the concept of SharePoint content types. I focused most of that issue on developing content types, but perhaps not enough time on explaining exactly what content types really are.<br /><br />So, I'm writing this relatively short overview. And I am saying relatively short, because any overview of content type must be vast, simply because of the span and importance of content types to any SharePoint solution.<br /><br /><b>SharePoint Content Types in five bullets:</b><br /><i>1. SharePoint content types is a term used for describing a collection of metadata</i><br />For example, an invoice content type may contain a set of metadata such as buyer, date of sale, terms of delivery, order total, shipping cost, etc. <br /><br /><i>2. Content types support user interface customization</i><br />You can define the appearance of a content type, both while editing, creating, and displaying data based on the content type. For example, you may want to display or edit your invoices in a page resembling an actual invoice. <br /><br /><i>3. Content types support behavior through workflows and event receivers</i><br />Data derived from a content type can behave in a certain fashion or react to specific events. For example, an invoice may need approval from a manager, or you may want to prevent deletion of approved invoices altogether.<br /><br /><i>4. Content types can have specific user interface elements attached</i><br />Through the use of CustomAction elements, content types can have unique menu options attached to the user interface. For example, you may want to add a 'Pay now' menu option or button to an invoice, and only for an invoice.<br /><br /><i>5. SharePoint content types support inheritance of properties, appearance, and behavior</i><br />You can create content type hierarchies, for example by having a root accounting document content type that defines a set of metadata, user interface options, and behavioral settings, and have the invoice child content type inherit those settings and override or extend the definition to include the necessary modifications for an invoice.<br /><br />If you think all of this sounds complex, don't worry. Content types are easy to use, and the complexity grows with your understanding. <br /><br /><b>How to Create Content Types</b><br />Creating content types is incredibly simple. You have access to the content types on the Site Settings page, accessible from the Site Actions menu. You can find the Site Content Type Gallery page by clicking the Site Content Types link in the Galleries section. <br /><br />All content types inherit from an existing content type. The Site Content Type Gallery page gives you an overview of all available content types for your site and from which parent content type each content type inherits.<br /><br />To create a new content type, click the Create button in the toolbar and type in a name and optional description for your new type. Then, select from which parent content type your new content type should inherit and choose or create a new display group or the type. Hit OK and you're done.<br /><br />Once your new type is created, you can edit the settings for the content type, such as any new columns you want to add to your type, attach workflows to your content type, or change the name and description. You can also reach the content type configuration page from the Site Content Type Gallery, by clicking on the content type name in the list.<br /><br /><b>How to Use a Content Type</b><br />You need to attach your content type to a list or library in order to create items based on the content type. Generally, you can attach content types that inherit from the Document content type to a library and content types that inherit from the Item content type to most other lists. <br /><br />To attach a content type to a list, go to the list settings of your chosen list and click the Advanced settings link on the Site Settings page. Click Yes in the section called "Allow management of content types?" and click OK. You will return to the Site Settings page and should now see a new section containing the content types. Click "Add from existing site content types", select your content type and click OK to add the content type.<br /><br />You can now return to your list view and click the down-arrow on the New button to create a new item based on your content type. Note that any additional content type columns you added earlier will also be added to the list.<br /><br /><b>Some Questions about Content Types</b><br /><i>Wait, this is too much, I prefer not to use content types. How can I avoid content types?</i><br />Your only choice to avoid using content types is not to use SharePoint. All data stored in SharePoint is stored using a content type. Even folders are content types. Therefore, you cannot simply choose to not use content types; you already are, if you are using SharePoint at all.<br /><br /><i>What do you mean? How can folders be content types?</i><br />The complete answer is beyond the scope of this short article, however, the fact that folders indeed are content types means you can also create new folder types and attach behavior and custom metadata to those folders. One example is to add a 'Zip Folder Contents' option to the folder menu.<br /><br /><i>Ok, you sold me, where can I learn more?</i><br />Mark Miller over at EndUserSharePoint.com has a <a href="http://www.endusersharepoint.com/?p=945">beginner's guide to content types</a> presentation available that will guide you through content types and show you some examples and best practices. EndUserSharePoint.com also has periodical workshop classes where you can learn even more about using content types. However, spaces in those classes are very limited, so I recommend you sign up for his newsletter to be notified whenever a new class is announced.<br /><br />Of course, I may be a bit biased, but if you want to learn to develop more complex content types and harness all the power available, get issue 2 of Understanding SharePoint Journal, called <a href="http://www.understandingsharepoint.com/journal/volume-1/issue-2">Developing SharePoint Content Types</a>. In that issue, I will teach you all the inner workings of SharePoint content types. Be prepared to get wet, though, because the content is targeted at people with some development experience.<br /><br />.b<br /><br />--<br />Bjørn Furuknap is a Senior Developer and Architect, passionate writer, and a SharePointholic. Author of "<a href="http://www.understandingsharepoint.com/userexperience/">Building the SharePoint User Experience</a>" and editor/author for "<a href="http://www.understandingsharepoint.com/journal/">Understanding SharePoint Journal</a>". <br /><br><br>Source: <a href="http://www.articletrader.com/">http://www.articletrader.com</a> ]]></description>
</item><item>
<title>Automatic business processes in SharePoint (part 1 of 3): SharePoint Designer Workflows</title>
<link>http://www.articletrader.com/computers/automatic-business-processes-in-sharepoint-part-1-of-3-sharepoint-designer-workflows.html</link>
<guid>http://www.articletrader.com/computers/automatic-business-processes-in-sharepoint-part-1-of-3-sharepoint-designer-workflows.html</guid>
<pubDate>Sat, 04 Oct 2008 00:00:00 -0500</pubDate>
<description><![CDATA[ This article was originally posted on <a href="http://furuknap.blogspot.com/">http://furuknap.blogspot.com/</a><br />Right, here is the first part of a three-part series on automating business processes in SharePoint. We will explore three different methods of doing Business Process Management, or BPM, using SharePoint and available tools.  The scenario is a simple helpdesk application in which users should be able to send emails and have an issue be raised and sent to an appropriate agent for resolution. We will use an email enabled list to receive emails and then use automated processes to route that email into the issue tracking system. The system will make sure that the issue is tracked and escalated as appropriate.   A few things worth noticing. This series will not result in a production ready system. It is meant to show different aspects of process automation, not to create the best method of doing a specific task such as creating a help desk application. The series is meant to show the entire process of creating the application.   First of all, lets draw a simple diagram to explain how the system is supposed to work.  <a href="http://lh4.ggpht.com/furuknap/SKXCW7-rIII/AAAAAAAAAEg/5Tz4Dth9_uM/s1600-h/IssueFlow5D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="358" alt="IssueFlow" src="http://lh4.ggpht.com/furuknap/SKXCYNfKx6I/AAAAAAAAAEk/tysDe8ghyVE/IssueFlow_thumb5D.png?imgmax=800" width="724" border="0" /></a>   So, in a few short sentences:  1. Receive a new email and start a new support issue (handled by SharePoint designer)  2. Escalate issue and find an available operative to handle the case (handled by an event receiver)  3. Update the issue, and if it is resolved, send a message to the customer. If not, go to step 2. (handled by a custom workflow in Visual Studio)  If you are going to do this in a production environment, don't. Basically what we are doing here is demonstrating different aspects of business process management, not doing a best practice thing. In a production system you would likely want to do all of this in a state machine workflow, or at least not do three different approaches to automation in one single system.  Let's get started with lesson one.   <h4>Solution walkthrough</h4>  <h5>Setup</h5>  Now, as you probably know, or will learn in about one second, SharePoint lists can receive email. This means that when someone sends an email to a certain address in the domain you set up, the email will be sent to a list which will then receive a new item containing that email.   There are problems, though, or at least quirks. Each list can only have one email address, meaning that if you want to have one system to handle multiple addresses you need to work around that and at the very least have multiple lists. We shall look at one option for doing this with a SharePoint Designer Workflow.   Also, only a certain number of list types can receive email, and sadly Custom lists are not on that list. The reason you cannot send email to a custom SharePoint list is that to enable email you need a very specific set up fields and properties set on the list. If there is public outcry for this I can create a new article later showing how to create a custom email enabled lists using features. Use furuknap&lt;[at]&gt;gmail.com for your requests, as usual.   Before we actually look at how this will be done, we need a few things set up. We want to receive email so we need an email enabled list. I will not go through setting this up. Email setup is a complex thing and we would be spending the entire day just setting up email, and most likely it would not be usable in your scenario anyway. At this point I will assume that you have set up an email enabled list and have that working. If you do not, I recommend <a href="http://www.google.com/search?q=email+enable+lists+in+sharepoint" target="_blank">Googling &quot;email enable lists in sharepoint&quot;</a>, but be prepared to spend a little time setting this up.  Second, since we need to track issues, we likely want to have a SharePoint list containing the issues. Remember we can only have certain types of lists be email enabled? Well, that does not prevent us from creating a custom list to hold the actual issues. After all, the first step in our automation is to create an issue, and we might as well do that in a custom list.  So, go ahead and create a few lists. We need one list to hold our incoming emails that will be email enabled. I use an announcement list since it is fairly basic. Any basic announcement list will do. Email enable it in list settings and give it a useful email alias. I call my announcement list 'support-receive' use support@lab-s02 as the email alias. You will likely use something else :-)  Second, create a custom list that will hold the issues. You need the following fields:  <ul>   <li>title (single line text) </li>    <li>message (multi line text) </li>    <li>sender (single line text) </li> </ul>  We shall expand this list in both the next articles in the series, but for now this will be enough. I have called my list 'Issues'. Use whatever name you like.   Ok, we should be ready to start working with the actual workflow.  <h5>SharePoint Designer workflow</h5>  Right, start SharePoint Designer and connect to your site.   Click File-&gt;New and select the SharePoint Content tab. Select Workflow in the left pane and Blank workflow (only option) in the right pane.   <a href="http://lh5.ggpht.com/furuknap/SKXCZ3GoXWI/AAAAAAAAAEo/y8zHyh3WYYw/s1600-h/step-15D.png" target="_blank"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="189" alt="step-1" src="http://lh3.ggpht.com/furuknap/SKXCakMnezI/AAAAAAAAAEs/qXoD92pPaYk/step-1_thumb5D.png?imgmax=800" width="244" border="0" /></a>   Next, click Ok to start the Workflow Designer wizard.   On the first screen of the Workflow Designer you only need to give your workflow a descriptive name and make sure you attach the workflow to the email enabled list (support-receive in my case).   You can leave the option to manually start the workflow. This means that when you want to start the workflow you do so manually by either opening the context menu on the item in the list or on the display form of the item.   <a href="http://lh4.ggpht.com/furuknap/SKXCcJUu5wI/AAAAAAAAAEw/L07O72PZlIU/s1600-h/step-2b5D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="205" alt="step-2b" src="http://lh3.ggpht.com/furuknap/SKXCdbf8DnI/AAAAAAAAAE0/p_-blnzoYKc/step-2b_thumb.png?imgmax=800" width="244" border="0" /></a>   If you like you can also set the workflow to start automatically, when an item is added and/or when an item is changed. You can modify this setting later so I suggest you leave it off at the moment. Your window should look something along the lines of this:  <a href="http://lh5.ggpht.com/furuknap/SKXCfduOCkI/AAAAAAAAAE4/igpeCtLWvFA/s1600-h/step-25D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="188" alt="step-2" src="http://lh6.ggpht.com/furuknap/SKXCgavTwaI/AAAAAAAAAE8/LUNKO4hKg1A/step-2_thumb.png?imgmax=800" width="244" border="0" /></a>   Click Next to get to the second page of the Workflow Designer wizard. Don't worry, we a soon done :-)  We are basically only going to do one thing here, at least in the first implementation, which again illustrates the point that you probably do not want to develop a workflow like this in a production environment. I mean, there will be only one task performed, so hardly any 'flow'. However, Windows Work Foundation sounds lame. But I digress.  One task to perform. First, write a descriptive name for this step, for instance 'Create issue item'. Next, click the Actions button and find Create a list item.   <a href="http://lh4.ggpht.com/furuknap/SKXChl2cTuI/AAAAAAAAAFA/NFbtK0ffU8Q/s1600-h/step-35D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="191" alt="step-3" src="http://lh6.ggpht.com/furuknap/SKXCiJlICOI/AAAAAAAAAFE/qfEXNXwJAsg/step-3_thumb.png?imgmax=800" width="244" border="0" /></a>   Note that the list of available actions may be different in your case. The list is dynamic and lists your most recent actions on top. Note also that you have a 'More actions...' option at the bottom. You can use that option to see even more workflow actions that you can perform, and, if you are up for some coding, you can also create your own actions that will appear in the list.  But that's another show.   Right. When you select Create List Item you will see that you get a text like in the screenshot below. This text, and similar texts for other workflow tasks, are used to configure the specific task. In our case we need to configure what item will be created and where. To do so, click the 'this list' link in the text next to the actions button.  Now, in the dialog that opens you get to configure the item that will be created. We want to create a new issue so make sure your issues list is selected. Next, you need to configure the fields of the new item. Any required fields in the list you select will automatically be populated for you, meaning at least Title and possibly others as well, depending on which fields are required.  <a href="http://lh3.ggpht.com/furuknap/SKXCjm63xnI/AAAAAAAAAFI/3F5OflM3ka0/s1600-h/step-45D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="200" alt="step-4" src="http://lh5.ggpht.com/furuknap/SKXCkTQmRzI/AAAAAAAAAFM/8vwna_uonBg/step-4_thumb.png?imgmax=800" width="244" border="0" /></a>   Ok, now things get a bit hairy, but the following steps and dialogs are about as important to workflows in SharePoint Designer as breathing every few seconds. I will explain more about this a bit later, but for now, just follow the instructions, look at the screenshots and make sure you get it right. If you end up with a different result, delete the wrong fields and try again.   <ol>   <li>In the Create New List Item dialog click the Title field and then Modify. A new mini dialog appears, called Value Assignment. </li>    <li>Next to the 'To this value' text box, click the fx button to set the field title to a lookup field. Yet another mini dialog appears. </li>    <li>Make sure you select Current item and in the Field, select E-Mail Subject. </li> </ol>  Here's a screenshot:  <a href="http://lh6.ggpht.com/furuknap/SKXClwcVMFI/AAAAAAAAAFQ/eeApBJxVsuc/s1600-h/step-55D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="209" alt="step-5" src="http://lh6.ggpht.com/furuknap/SKXCmrnejQI/AAAAAAAAAFU/DKHjE8_pQsk/step-5_thumb.png?imgmax=800" width="244" border="0" /></a>   Ok, so what is actually going on here? The process is important but may be confusing the first time you see it, especially the lookup fields in step 3.   Now, the following paragraphs will go into some rather deep and perhaps confusing detail on how the dialogs work. I will explain as best I can, but if you feel you are in over your head, just skip to the final steps of setting up this workflow.  <h5>Value assignment dialog</h5>  First of all we decide we want to set a field, in this case on an item. In step 2, also a common dialog in SPD, we basically have two options to setting a text field. The [...] button lets us set the value of a field to a text that you type in. The [fx] button lets us set the value of field by looking up another field in the site.   Before we look at what goes on there, though, note that different field types yield different input options. For text field you get a text box, but for a date/time field you get a calendar, while for a Yes/No field you get a drop-down and for a person field you get to look up a person in several different places, including the address book and SharePoint users. I have included some screen shots below.  <table cellspacing="0" cellpadding="2" width="400" border="0"><tbody>     <tr>       <td valign="top" width="133"><a href="http://lh5.ggpht.com/furuknap/SKXCnABnOCI/AAAAAAAAAFY/wEVY_wmgDT4/s1600-h/step-5a5D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="225" alt="step-5a" src="http://lh6.ggpht.com/furuknap/SKXCn_dx0-I/AAAAAAAAAFc/N5B5hVNKcLY/step-5a_thumb.png?imgmax=800" width="244" border="0" /></a> </td>        <td valign="top" width="133"><a href="http://lh3.ggpht.com/furuknap/SKXCoUqInXI/AAAAAAAAAFg/NJii9U7Pku8/s1600-h/step-5b5D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="step-5b" src="http://lh4.ggpht.com/furuknap/SKXCpPoOFKI/AAAAAAAAAFk/6jb3YUdeHbg/step-5b_thumb.png?imgmax=800" width="227" border="0" /></a> </td>        <td valign="top" width="133"><a href="http://lh4.ggpht.com/furuknap/SKXCphEIFEI/AAAAAAAAAFo/mMBUpyux54w/s1600-h/step-5c5D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="152" alt="step-5c" src="http://lh6.ggpht.com/furuknap/SKXCqCocyDI/AAAAAAAAAFs/XbcR2c9bvyo/step-5c_thumb.png?imgmax=800" width="244" border="0" /></a> </td>     </tr>   </tbody></table>  Ok, so we can set fields of our list item to a set value which is useful in a range of scenarios. What we want to do in our case, though, is to set different fields to the values of another object, namely the item that was created with the incoming email.   <h5>Define Workflow Lookup dialog</h5>  In step 3 of setting the value of the title field we got the Define Workflow Lookup dialog when we clicked the [fx] button. The dialog can be a bit confusing as well, but after a few paragraphs, things should be as clear as... something really clear.   The lookup dialog allows you to find other items in the SharePoint site to use to set the value of a field. There are basically two fields in the dialog, which item from which to use a value and what value of that item should be used.   For our example it was rather simple. Remember that the workflow is initiated by the item in the email enabled receiver list. thus, what is listed in the lookup dialog as 'Current item' is actually the item in the receiver list, not the item you are currently creating. Important distinction.   What makes the workflow lookup dialog a bit more complex is that you can work not only with the current item, but with any item in your site. Look at the screen shot below.  <a href="http://lh3.ggpht.com/furuknap/SKXCqi1z1gI/AAAAAAAAAFw/OmDQTBe-SGU/s1600-h/step-6a5D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="step-6a" src="http://lh4.ggpht.com/furuknap/SKXCrQeZV6I/AAAAAAAAAF0/URykcEzVD7g/step-6a_thumb.png?imgmax=800" width="224" border="0" /></a>   As you can see we can work with but the current item, something called Workflow data, which we will cover later, as well as all lists in the site. If you select any list directly, i.e. not current item or workflow data, the workflow lookup changes to let you set up how you will find the relevant item in the lookup list.   <a href="http://lh5.ggpht.com/furuknap/SKXCr1nUW0I/AAAAAAAAAF4/WJ_nTVYyY7k/s1600-h/step-6b5D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="243" alt="step-6b" src="http://lh6.ggpht.com/furuknap/SKXCsqk27pI/AAAAAAAAAF8/2G5E_er01-M/step-6b_thumb.png?imgmax=800" width="244" border="0" /></a>   The new section of the dialog allows you to select which field you will use to find the new item. ID is often a good choice since it is unique for each item. However, you also need to select the value which the said field will have. And there you are with the [fx] button again. Clicking that will yield a new Define Workflow Lookup dialog.  Think it is confusing? It is. At this point you are doing multi level lookups across several lists. It can be really powerful but you need to wrap your head around it.   <h5>Final tasks</h5>  Ok, back to non-head-exploding land.   If you have set up the title field properly, here's the good news. Do the same to the Message and Sender fields, mapping to the fields 'Body' and 'E-mail From' of the current item, and we are done.   Depending on where you are at the moment, click back to the Create New List Item dialog, where, at present, you should have configured the title field. To add more fields to the new item, click Add. Select the field you want to set (Message and Sender in order) and map it to the correct field of the current item, as described in the last paragraph. Your final field setup for the new item should look something like this:  <a href="http://lh4.ggpht.com/furuknap/SKXCu07PWjI/AAAAAAAAAGA/G7Xru6J4ECY/s1600-h/step-75D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="192" alt="step-7" src="http://lh5.ggpht.com/furuknap/SKXCvXdaqVI/AAAAAAAAAGE/RSnTq7ugW-k/step-7_thumb.png?imgmax=800" width="244" border="0" /></a>   That's it! We have create a new SharePoint Designer workflow. Just hit Ok and then Finish and SharePoint Designer will go off and do some configuration magic to attach the workflow to your list.   <h4>Testing</h4>  Now that you have your workflow set up, go ahead and test it by sending an email to your list. If you have your email enabled list set up properly you should get a new item in the receiving list. Open the list in the web interface.   When the item arrives, and it make take a minute or two, go ahead and click the item or open its context menu to find the Workflows available to that item. You should find your workflow under the 'Start a New Workflow' section. Click it and verify that it actually creates a new item in your Issues list.   <h4>More fun stuff!</h4>  Since we are using a receiver list to pipe our incoming email into an issues list we can surely use different receiver lists as well. Let's up the complexity a bit.   We can now use two email enable lists, say one called support-receive and one called invoice-receive. Each can have a different email alias making it possible to pipe for instance <a href="mailto:support@example.com">support@example.com</a> as well as <a href="mailto:invoice@example.com">invoice@example.com</a> to the same issue list.   However, we have no method of differentiating the issues at present. So, in order to do this, add a new field to your issues list in SharePoint called 'Issue Type'. The field will be a Choice field and the choices will be 'Support' and 'Invoice'. You can add more if you have more email enabled lists.   Oh, and one thing. You may want to make this field a site column rather than just a list column. You will see why in the next article.   Go back to SharePoint designer and modify your workflow. To do this, open the Workflows tree node in the folder list, then open your workflow and then double-click the xoml file to open the Workflow Designer again. Note that you can click the Back button to change how the workflow is started, but you cannot change the list to which it is associated.   Back on the second step of the wizard, the one with 'Conditions' and 'Actions', click on the 'Issues' link in the text 'Create item in Issues'. this will reopen the Create New List Item dialog.   Click to add a new field. You choices field 'Issue Type' should be there now. Since you are working on the support-receive list, select to set the field to Support. See screenshot for how it looks on my machine.  <a href="http://lh4.ggpht.com/furuknap/SKXCxIvCilI/AAAAAAAAAGI/K8LgQ96gGqc/s1600-h/step-85D.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="189" alt="step-8" src="http://lh4.ggpht.com/furuknap/SKXCylTkRDI/AAAAAAAAAGM/KI3fLS4ePSY/step-8_thumb.png?imgmax=800" width="244" border="0" /></a>   Great. Now, new items sent to the support-receive will be marked as being of type Support.   Repeat the entire process of creating the workflow for your invoice-receive list as well, but change the value of the issue type to 'Invoice'. Repeat for any other receiving lists as well, and suddenly you have not only a way to receive emails to multiple addresses, but the beginning of a simple classification system as well.   <h4>Ending it all</h4>  Ok, so this may not have been incredibly impressive, but this is the start of some really cool stuff you can do. We shall explore this a bit further in the next article where we go into some more advanced things we can do with SPD and then head down into another cool aspect of business process automation: Event receivers. <br /><br />You can read the next two articles in the series here:<br /><br /><a href="http://furuknap.blogspot.com/2008/08/automating-business-processes-in_18.html">Automating business processes in SharePoint: SharePoint Event Receivers (Part 2 of 3) </a><br /><br /><a href="http://furuknap.blogspot.com/2008/08/automating-business-processes-in_27.html">Automating business processes in SharePoint: Visual Studio Workflows (Part 3 of 3) </a><br /><br /><br />--<br />Bjørn Furuknap is a senior solutions architect focusing on SharePoint and collaborative technologies. He is currently authoring the book Building the SharePoint User Experience' (<a href="http://www.understandingsharepoint.com/userexperience/">http://www.understandingsharepoint.com/userexperience/</a>)<br><br>Source: <a href="http://www.articletrader.com/">http://www.articletrader.com</a> ]]></description>
</item><item>
<title>Send a SharePoint document library file as email</title>
<link>http://www.articletrader.com/computers/send-a-sharepoint-document-library-file-as-email.html</link>
<guid>http://www.articletrader.com/computers/send-a-sharepoint-document-library-file-as-email.html</guid>
<pubDate>Tue, 23 Sep 2008 00:00:00 -0500</pubDate>
<description><![CDATA[ This article was orignially posted to <a href="http://furuknap.blogspot.com/2008/07/send-sharepoint-document-library-file.html">http://furuknap.blogspot.com/2008/07/send-sharepoint-document-library-file.html</a><br /><br />Ever wanted to send a SharePoint item by email to someone? No? Well, neither have I. turns out, someone else did, though, and they did not know how, so I thought I'd help out. And you never know, it might turn out to be you next time, and what will you do then? Now you can just remember that weird Norwegian guy who wrote that thing back in the days and come here to pick up your solution. And, to save you some time, I'll actually upload the entire solution for you, ready to use with just one simple step to do.<br /><br /><b>Scope</b><br />Ok, so what is our scope. I want to have some way of sending an individual file from a SharePoint library to someone. The file should be sent as an attachment and I should just have to enter the recipients email and perhaps a message. <br /><br />To accomplish this I want to add a choice to the drop-down menu that appears on a library item when you hover-and-click a library item.<br /><br />Clicking on that item should open up a form that I can use to fill out recipient address and a message. When I click a Send button on that page I should return to the list. <br /><br />Let's get down to business.<br /><br /><b>Solution walk-through</b><br />For this project I will use WSPBuilder that I wrote about in my <a href="http://furuknap.blogspot.com/2008/07/basic-setup-of-sharepoint-visual-studio.html">Basic setup of SharePoint Visual Studio project article</a>. Make sure you have WSPBuilder with the Visual Studio extensions installed, it will save you tons of work and make SharePoint development a joy. So much for advertising.<br /><br />Our ingredients:<br /><br />- One visual studio 2005 or 2008.<br />- <a href="http://codeplex.com/WSPBuilder">WSPBuilder with Visual Studio Extensions</a>. <br />- SharePoint in any v3 flavor, WSS or MOSS<br />- <a href="http://www.aisto.com/roeder/dotnet/">.Net Reflector</a><br />- An SMTP-server, like that of your ISP or your own<br /><br />Step 1: Setup<br /><br />First, start by creating a new WSPBuilder project in Visual Studio. Use whatever name you like, for example SendAsEmail as I did. Add a new empty feature to the project. With WSPBuilder extensions it is simply a matter of right-clicking the project in the solution explorer and click Add->New item. The items available to you includes an empty feature. Write a nice description and make sure the feature is web scoped.<br /><br />Second, add a class file. I like to add my class files to a folder in the Project called FeatureCode. The reason for this is that WSPBuilder will also use this folder to add custom code, and I like to keep my code in one place in small projects such as this. To do so, right-click the project again and click Add->New folder. Call it FeatureCode. Then, right-click that folder and click Add->Class. Browse to the Visual C# Project items to find the Class file. Call it again whatever you like. I call mine SendAsEmail.cs. <br /><br />Third, add references to your project. Right-click the References in solution explorer and add references to Windows SharePoint Services (microsoft.sharepoint.dll) and System.Web.<br /><br />Finally, create a new blank ASPX page to your solution. This page will be the custom form we will use to input the recipients email and the message text. To do so, first right-click on the 12\Template folder under your project in the solution explorer. Click Add->New folder and call it Layouts. No, you cannot call this anything else, it must be named Layouts. This folder largely corresponds to the _layouts virtual directory in SharePoint and we want to put our file there to make it available everywhere. Next, right-click the layouts folder and click Add->New item. Again, browse to the Visual C# Project items and find a Text file item. There is no ASPX page item to add to a non-website project, but we can still get one by naming our new text file SendAsEmail.aspx. Or something else, the important thing is to call it [something].aspx. <br /><br />Now to start the actual development. <br /><br />Step 2: Create a custom action feature<br /><br />Open the empty feature you created in step 1. Browse to the folder in the solution explorer and open the elements.xml file. In the elements.xml file, add the following code:<br /><br />1 &lt;?xml version="1.0" encoding="utf-8" ?>    <br />2 &lt;Elements xmlns="http://schemas.microsoft.com/sharepoint/">    <br />3   &lt;CustomAction Title="Send as email"    <br />4                 Id="SendAsEmailECB"    <br />5                 RegistrationType="List"     <br />6                 RegistrationId="101"     <br />7                 ImageUrl="/_layouts/images/MSG16.GIF"     <br />8                 Location="EditControlBlock"     <br />9                 Sequence="225">   <br />10       &lt;UrlAction Url="~site/_layouts/SendAsEmail.aspx?ItemId={ItemId}&amp;ListId={ListId}" />   <br />11   &lt;/CustomAction>   <br />12    <br />13 &lt;/Elements> <br /><br />The customaction element allows you to modify action menus all around SharePoint. There are a few lines here that are critical to accomplish what we want. Line 5, RegistrationType, states that we want this to be linked to a list, and line 6, RegistrationId, states that the list type should be from template 101 or Document Library. If you develop your own list templates you can link a custom action to only that particular list by modifying RegistrationId to match you template type. List 8, Location, states that we want to add this to the EditControlBlock. That's the name of the hover-and-lick menu where we want our custom action to appear. <br /><br />Inside the CustomActions element we have a URL Action element. That simply tells SharePoint what should happen when we click that link. If you notice the Url-attribute it holds two tokens, ItemId and ListId. these tokens will be filled in for us by SharePoint. Tokens are widely used in SharePoint so I wont go into them in detail here, these two should be self-explanatory. Perhaps I will write an article on tokens one day.<br /><br />Basically, that's it for the feature code. If you are using WSPBuilder you can actually build, deploy and activate this feature and the menu item will appear. Of course, we haven't actually built any code yet, so it will fail miserably. Let's move on.<br /><br />Step 3: Create the asp.net page to get input from user<br /><br />Open the SendAsEmail.aspx page from the Layouts folder. Now, I am extremely far from being a designer, and I believe in separating code from design in any case so I'll just make this extremely simple design-wise. There are a few things that we will need to do, though. <br /><br />First, paste the following code into the aspx-file. Make sure you are in code view and not in design view:<br /><br />&lt;><br />&lt;> <br /><br />&lt;asp:Content ID="main" runat="server" ContentPlaceHolderID="PlaceHolderMain"> <br /><br />&lt;table><br />&lt;tr>&lt;td>&lt;asp:label runat="server" ID="lblSendTo" Text="Send to:"/>&lt;/td>&lt;td>&lt;asp:TextBox runat="server" ID="txtSendTo" />&lt;/td>&lt;/tr><br />&lt;tr>&lt;td>&lt;asp:label runat="server" ID="lblMessage" Text="Message:"/>&lt;/td>&lt;td>&lt;asp:TextBox runat="server" ID="txtMessage" TextMode="MultiLine" Rows="5" />&lt;/td>&lt;/tr><br />&lt;tr>&lt;td>&lt;asp:button runat="server" ID="btnSend" Text="Send message" />&lt;/td>&lt;/tr><br />&lt;/table> <br /><br />&lt;/asp:Content><br /><br />Second, get the strong name of your assembly, you need to paste that into where it says [STRONG NAME]. To do so, and I am assuming you are still using WSPBuilder, hit Build (Menu->Build->Build solution). Start up .net Reflector and open your assembly dll, often located in My documents\Visual Studio 2005\Projects\Solutionname\Projectname\bin\debug. At the bottom of reflector you will now see your strong name.<br /><br />Simply copy the entire strong name, all four parts. Paste this into the code where it says [STRONG NAME]. <br /><br />You may also need to edit the Inherits-attribute of the Page directive. I have written NittiTre.SendAsEmail since that is the namespace and name of the class I will be writing in the next step. <br /><br />The page itself is fit into the application.master of the SharePoint site. This master page has a contentplaceholder called PlaceHolderMain in which we put a simple table with a few controls with IDs of lblSendTo, lblMessage, btnSend, txtSendTo and txtMessage. You can basically hand this page over to your designer, but make sure that these IDs remain the same. This is important as we will be wiring up these controls in a code-behind file, and if the IDs do not match we get a runtime exception. <br /><br />Let's move over to the code.<br /><br />Step 4: Write the class to send the email<br /><br />Finally it's time to do some coding. <br /><br />Start by adding a few Using statements to the top to make our code a bit more readable:<br /><br />1 using System;    <br />2 using System.Collections.Generic;    <br />3 using System.Text;    <br />4 using System.Web.UI;    <br />5     <br />6 using System.Net.Mail;    <br />7 using Microsoft.SharePoint;    <br />8 using Microsoft.SharePoint.WebControls;    <br />9 using System.Web.UI.WebControls;<br /><br />Second, make sure your class inherits from LayoutsPageBase and add some controls that will have names matching the IDs of the controls we added on the aspx page. We will also add a few variables to hold our mail server configuration:<br /><br />10    <br />11 namespace NittiTre   <br />12 {   <br />13     public class SendAsEmail : LayoutsPageBase   <br />14     {   <br />15    <br />16         protected Label lblSendTo;   <br />17         protected Label lblMessage;   <br />18         protected Button btnSend;   <br />19    <br />20         protected TextBox txtSendTo;   <br />21         protected TextBox txtMessage;   <br />22    <br />23         private string mailServer = ""; // YOU NEED TO ADD SOMETHING HERE!   <br />24         private int mailPort = 25;   <br />25 <br /><br />Ensure that you add the host name of your SMTP server in line 23.<br /><br />See line 11 and 13? The namespace and the name of the class makes up what we should put in the aspx file Page inherits directive. <br /><br />Since we want to have a button with an event handler we need to make sure that all our controls are created before the event handler wireup completes. A good place to do this is in the OnLoad method, so lets override that:<br /><br />26         protected override void OnLoad(EventArgs e)   <br />27         {   <br />28             EnsureChildControls();   <br />29         }   <br />30 <br /><br />The EnsureChildControls makes sure that CreateChildControls() are called once and only once. If you happen to call EnsureChildControls again later in the code it will not create new child controls thus saving us the trouble of finding out if the controls have been added or not.<br /><br />If you have ever experience adding event handlers to your controls and having them not fire it is often because you hooked up the event handler too late in the page life cycle. Often, an event handler not firing is because of just that. Simple fix, just call EnsureChildControls in your onload overridden method. <br /><br />Of course, for CreateChildControls to actually, well, create child controls we need to override that method and make sure we hook up our event handler. I've also added a default text to the message box:<br /><br />31         protected override void CreateChildControls()   <br />32         {   <br />33             btnSend.Click += new EventHandler(btnSend_Click);   <br />34    <br />35             txtMessage.Text = "Hello, this file is sent from SharePoint";   <br />36         }   <br />37 <br /><br />Now for the bulk of our code, the btnSend_Click method that will fire when someone clicks that button. Notice line 33? That is where we hook it up. Now for the code. I've written inline comments to describe what is going on rather than commenting afterwards. <br /><br />38         void btnSend_Click(object sender, EventArgs e)   <br />39         {   <br />40             EnsureChildControls(); // Has been called already, but let's make sure...   <br />41    <br />42             // Find the list and item ids from the querystring   <br />43             try   <br />44             {   <br />45                 Guid listId = new Guid(Server.UrlDecode(Request.QueryString["ListId"]));   <br />46                 int itemId = int.Parse(Request.QueryString["ItemId"]);   <br />47    <br />48                 // Find our item from the current web   <br />49                 SPWeb web = this.Web;   <br />50                 SPListItem item = web.Lists[listId].GetItemById(itemId);   <br />51    <br />52                 // Start building our mail message       <br />53                 string senderMail = web.CurrentUser.Email;   <br />54                 string recipientMail = txtSendTo.Text;   <br />55                 MailMessage message = new MailMessage(senderMail, recipientMail);   <br />56                 message.Body = txtMessage.Text;   <br />57                 message.Subject = item.DisplayName;   <br />58    <br />59                 // Add the file as an attachment   <br />60                 SPFile file = item.File;   <br />61                 Attachment attachment = new Attachment(file.OpenBinaryStream(), file.Name);   <br />62                 message.Attachments.Add(attachment);   <br />63    <br />64                 // ...and finally try sending   <br />65                 SmtpClient smtp = new SmtpClient(mailServer, mailPort);   <br />66                 smtp.Send(message);   <br />67                 Response.Clear();   <br />68                 Response.Redirect(web.Lists[listId].DefaultViewUrl);   <br />69             }   <br />70             catch    <br />71             {   <br />72                 throw;   <br />73             }   <br />74         }   <br />75     }   <br />76 }<br /><br />Most of this code consists of finding information about the item selected and then start building the mail message from that information along with the input from the form. <br /><br />Note that I have not added much error handling. This is bad and you should add better error handling code, especially around the SmtpClient.Send method call. A lot of things can go wrong when attempting to send an email to another server. Make sure you at least throw any exceptions up to the user so that they get an error message. <br /><br />If everything goes according to plan, we send the user back to the list in line 68. <br /><br />That is it. Nothing more. Let's build, deploy and activate. I've uploaded a zipped solution containing everything as written here. You can download that from <a href="http://furuknap.googlepages.com/SendAsEmail.zip">http://furuknap.googlepages.com/SendAsEmail.zip</a>. Do remember to edit your SMTP Server, that should be the only thing you need to do.<br /><br />Step 4: Deploy<br /><br />If you have been wise and paid attention you are using WSPBuilder. If so, right click you project in the Solution Explorer, click WSPBuilder->Build WSP. Next, do the same again, and note that now that you've built the WSP, more options become available in the menu. Click Deploy. Hang around for a while and your solution will be deployed. <br /><br />Next, you need to activate your feature. Open your SharePoint site and go to Site Settings. Under web features you will find your SendAsEmail feature. Click activate and your document libraries now gets the new feature of sending a document library item as an attachment.<br /><br /><b>Finally!</b><br />Congratulations, you have created a hopefully useful feature. Go ahead, play around with it. Suggestions for improvements may be:<br /><br />- Implement sending all documents in a folder at once (hint: folders are simply content types and you can limit the edit control box to only apply to certain content types)<br /><br />- Look up recipients names in an existing contact list to avoid misspelling names<br /><br />- Send to multiple recipients<br /><br />- Add more mail related parameters such as Cc, Bcc, encryption, etc.<br /><br />- Save user preferences for these parameters<br /><br />Good luck, and let me know how it turns out.<br /><br />--<br />Bjørn Furuknap of Norway holds more than 10 MCP titles, including every SharePoint certification from Microsoft. He has worked on SharePoint projects for all the largest companies in Norway as well as having been hired by Microsoft to develop SharePoint solutions. He also writes regularly for SharePoint Magazine and in his SharePoint blog at <a href="http://furuknap.blogspot.com/">http://furuknap.blogspot.com/</a>.<br><br>Source: <a href="http://www.articletrader.com/">http://www.articletrader.com</a> ]]></description>
</item>
</channel>
</rss>
