<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SharePoint Fun &#187; Workflows</title>
	<atom:link href="http://blog.qumsieh.ca/tag/workflows/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.qumsieh.ca</link>
	<description>Developer's blog related to ASP.NET, SharePoint and Telerik Web Controls</description>
	<lastBuildDate>Fri, 27 Jan 2012 19:08:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>SharePoint Designer Workflow Pause Until Date Change</title>
		<link>http://blog.qumsieh.ca/2012/01/27/sharepoint-designer-workflow-pause-until-date-change/</link>
		<comments>http://blog.qumsieh.ca/2012/01/27/sharepoint-designer-workflow-pause-until-date-change/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 19:08:36 +0000</pubDate>
		<dc:creator>shereen</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[SharePoint Designer]]></category>
		<category><![CDATA[Workflows]]></category>

		<guid isPermaLink="false">http://blog.qumsieh.ca/?p=892</guid>
		<description><![CDATA[So what happens when you&#8217;ve built out a SharePoint Designer workflow with a Pause Until Date activity, and then the date changes on you? Obviously, we want to the workflow to handle this situation and update the Delay logic accordingly. Scenario Let&#8217;s assume we have a Date Received column. After 2 weeks of initial item [...]]]></description>
			<content:encoded><![CDATA[<p>So what happens when you&#8217;ve built out a SharePoint Designer workflow with a <strong>Pause Until Date</strong> activity, and then the date changes on you? Obviously, we want to the workflow to handle this situation and update the <strong>Delay</strong> logic accordingly.</p>
<p><strong>Scenario</strong></p>
<p>Let&#8217;s assume we have a <strong>Date Received</strong> column. After 2 weeks of initial item creation, we want to send a reminder notification to the user. So based on the value of <strong>Date Received</strong> column, add <strong>14</strong> days, and if <strong>Today</strong> matches that value, then send a notification. For this we need the <strong>Pause Until Date </strong>activity, so we do a quick evaluation, if there is a match, send the reminder, otherwise, pause until we reach that date.</p>
<ol>
<li>User enters <strong>Jan 13, 2012</strong> in date received and creates new item.</li>
<li>Workflow kicks off and determines that<strong> Jan 13, 2012 </strong>+ <strong>14</strong> days is equal to <strong>Jan 27, 2012</strong>.</li>
<li>Workflow checks if <strong>Today</strong> is equal to <strong>Jan 27, 2012</strong>. If it is, send the email reminder.</li>
<li>If it isn&#8217;t, <strong>Pause Until Jan 27, 2012</strong>. You will see the pause activity log to the workflow history list the day it&#8217;s planning to pause until.</li>
</ol>
<p>Perfect right, works great. Now what happens when a user edits the item and changes the date received to<strong> Jan 17, 2012</strong>. We want the delay to postpone until the 31st of Jan, not the 27th. I&#8217;ve read a great deal of posts that document how others have tackled this problem, ranging from an event handler to some sort of custom workflow logic. In our case, since the forms were<a href="http://blog.qumsieh.ca/2009/05/15/how-to-change-the-default-editform-newform-and-dispform/"> custom ASP.NET forms submitting programmatically to the list</a>, it was easy enough for me to track any changes to the date received column, and if I do find that it has changed, I simply stop and restart the workflow within the submit event. The logic looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// stop and restart the workflow if date received is different</span>
<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>dtcDateReceived.<span style="color: #0000FF;">SelectedDate</span>.<span style="color: #0000FF;">ToShortDateString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">!=</span> dateReceived.<span style="color: #0000FF;">Value</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// stop workflow</span>
    SPWorkflowCollection itemWorkflowCollection<span style="color: #008000;">=</span> item.<span style="color: #0000FF;">Workflows</span><span style="color: #008000;">;</span>
&nbsp;
    SPWorkflowAssociation workflowAss <span style="color: #008000;">=</span> yearEnd.<span style="color: #0000FF;">WorkflowAssociations</span><span style="color: #000000;">&#91;</span><span style="color: #008000;">new</span> Guid<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;369dcef7-b35c-48f1-bf2f-5b9f53d568ee&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>SPWorkflow itemWorkflow <span style="color: #0600FF;">in</span> itemWorkflowCollection<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>itemWorkflow.<span style="color: #0000FF;">ParentAssociation</span>.<span style="color: #0000FF;">Id</span> <span style="color: #008000;">==</span> workflowAss.<span style="color: #0000FF;">Id</span> <span style="color: #008000;">&amp;&amp;</span> <span style="color: #000000;">&#40;</span>itemWorkflow.<span style="color: #0000FF;">InternalState</span> <span style="color: #008000;">&amp;</span> SPWorkflowState.<span style="color: #0000FF;">Running</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">==</span> SPWorkflowState.<span style="color: #0000FF;">Running</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            SPWorkflowManager.<span style="color: #0000FF;">CancelWorkflow</span><span style="color: #000000;">&#40;</span>itemWorkflow<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            site.<span style="color: #0000FF;">WorkflowManager</span>.<span style="color: #0000FF;">StartWorkflow</span><span style="color: #000000;">&#40;</span>item, workflowAss, workflowAss.<span style="color: #0000FF;">AssociationData</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            break<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>For completeness, this is how I set the <strong>hidden</strong> field on load that stores the original Date Received value.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// set date received to see if it changes</span>
 dateReceived.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> Convert.<span style="color: #0000FF;">ToDateTime</span><span style="color: #000000;">&#40;</span>yearEndItem<span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;Date Received&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">ToShortDateString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>Thanks Tony for the original post that helped me build out the logic above:</p>
<p><a href="http://www.tonytestasworld.com/post/Howto-Start-a-Sharepoint-Workflow-Programmatically.aspx">http://www.tonytestasworld.com/post/Howto-Start-a-Sharepoint-Workflow-Programmatically.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.qumsieh.ca/2012/01/27/sharepoint-designer-workflow-pause-until-date-change/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Failed To Load Workflow Error in SharePoint Designer</title>
		<link>http://blog.qumsieh.ca/2010/01/16/failed-to-load-workflow-error-in-sharepoint-designer/</link>
		<comments>http://blog.qumsieh.ca/2010/01/16/failed-to-load-workflow-error-in-sharepoint-designer/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 23:06:11 +0000</pubDate>
		<dc:creator>shereen</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[SharePoint Designer]]></category>
		<category><![CDATA[Workflows]]></category>

		<guid isPermaLink="false">http://blog.qumsieh.ca/?p=631</guid>
		<description><![CDATA[Ok I thought I&#8217;d post on this because it stumped me for close to 2 hours. So in my scenario, I have a WSS 3.0 installation with several SharePoint Designer workflows built. Many of these workflows use the Useful SharePoint Designer Custom Workflow Activities solution available on codeplex. After doing a migration from one server [...]]]></description>
			<content:encoded><![CDATA[<p>Ok I thought I&#8217;d post on this because it stumped me for close to 2 hours. So in my scenario, I have a WSS 3.0 installation with several SharePoint Designer workflows built. Many of these workflows use the <a href="http://spdactivities.codeplex.com/">Useful SharePoint Designer Custom Workflow Activities</a> solution available on codeplex. After doing a migration from one server to another, I found that when I attempted to open up my workflows that contained those custom activities, I would get an error:</p>
<blockquote><p><span style="color: #ff0000;">Failed to load workflow.</span></p></blockquote>
<p>Really frustrating error because it gives you absolutely nothing to go on. I do want to mention that I also tried building a brand new workflow and selecting one of these custom workflow activities and the behavior was odd. If i tried to add one as an ACTION inside my workflow designer, nothing would happen. No error, but the activity wasn&#8217;t added to the step either. It was as if my click/selection had no effect.</p>
<p>So I made the decision to completely remove and reinstall the custom activities. The codeplex solution comes nicely packaged using the SharePoint Installer, so all I had to do was run a remove and then a reinstall. Normally, a final step to getting this working according to the InstallGuide.txt is to:</p>
<blockquote><p>Go to Central Administration -> Application Management -> Manage Web Application Features and activate the feature for desired web applications (usually it&#8217;s Sharepoint &#8211; 80 or Sharepoint &#8211; 443).</p></blockquote>
<p>The odd thing was that I found this step was already done for me and the solution was listed as already deployed. So back to SharePoint Designer I went, double clicked on the .xoml file, damn, same error! I found several blog posts indicating that I should clear the SharePoint Designer cache. So I closed down SD, deleted the folders starting with 12.x.x.x and loaded SD back up. I tried to open my xoml file, still no luck, same error.</p>
<p>At this point I was getting pretty confused. I manually did a check of the Assembly to make sure it contained the DP.SharePoint.Workflow dll, I double checked the Features folder to make sure it contained the DP.SharePoint.Workflow folder and I make sure the .ACTIONS file was contained within the Workflow folder and that the permissions on it were not wonky. I also verified the web.config contained the safe control entries for that dll. All looked good to me.</p>
<p>FINALLY, I decided to compare my web.config against the old server&#8217;s web.config to make sure that I wasn&#8217;t missing anything. I did a quick search on DP and found that the old web.config contained one more entry than my new web.config did:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;authorizedType</span> <span style="color: #000066;">Assembly</span>=<span style="color: #ff0000;">&quot;DP.Sharepoint.Workflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0298457208daed83&quot;</span> <span style="color: #000066;">Namespace</span>=<span style="color: #ff0000;">&quot;DP.Sharepoint.Workflow&quot;</span> <span style="color: #000066;">TypeName</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">Authorized</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>So it would appear that I was missing this authorized type necessary for custom workflow activities. How or why this did not get added when I did my reinstall, I have no idea. But once that entry was added back, I was good to go again. My workflows open just fine without error.</p>
<p>I hope this helps someone else out there!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.qumsieh.ca/2010/01/16/failed-to-load-workflow-error-in-sharepoint-designer/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>SharePoint Designer Custom Workflow &#8211; List Item Not Found</title>
		<link>http://blog.qumsieh.ca/2009/10/08/sharepoint-designer-custom-workflow-list-item-not-found/</link>
		<comments>http://blog.qumsieh.ca/2009/10/08/sharepoint-designer-custom-workflow-list-item-not-found/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 19:03:15 +0000</pubDate>
		<dc:creator>shereen</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Custom Activity]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[SharePoint Designer]]></category>
		<category><![CDATA[Workflows]]></category>
		<category><![CDATA[WSS]]></category>

		<guid isPermaLink="false">http://blog.qumsieh.ca/?p=516</guid>
		<description><![CDATA[So this particular error seems to be quite common, based on posts I&#8217;ve read here and here. If you&#8217;ve built a SharePoint Designer workflow and utilized the Update List Item activity, you may have run into a workflow error that logs an Outcome of: List Item Not Found For this particular scenario, here was my [...]]]></description>
			<content:encoded><![CDATA[<p>So this particular error seems to be quite common, based on posts I&#8217;ve read <a href="http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/c3f9f1e5-b868-4daf-b07f-034aeb8658bc" target="_blank">here</a> and <a href="http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/MS-SharePoint/Q_24445904.html" target="_blank">here</a>. If you&#8217;ve built a SharePoint Designer workflow and utilized the <strong>Update List Item</strong> activity, you may have run into a workflow error that logs an <strong>Outcome</strong> of:</p>
<blockquote><p><span style="color: #ff0000;">List Item Not Found</span></p></blockquote>
<p><span style="color: #ff0000;"><span style="color: #000000;">For this particular scenario, here was my setup:</span></span></p>
<ol>
<li>I have two lists: <strong>Survey</strong> and <strong>Customers</strong></li>
<li><strong>Survey</strong> has a custom column called <strong>Customer</strong> that is of type <strong>Lookup</strong>. This column is configured to lookup on the <strong>Title</strong> column in <strong>Customers</strong></li>
<li>My custom SD workflow has a single activity, the <strong>Update List Item</strong> activity, configured to update the <strong>Customers</strong> list, on the <strong>Survey Status</strong> column, and the criteria for determining what item to update is based on the <strong>Customer</strong> lookup in the <strong>Survey</strong> list</li>
</ol>
<p>Pretty straight forward stuff. I&#8217;ve done this a thousand times before and it&#8217;s worked without issue. However, I ran into a specific list where the workflow would error every single time, with the <span style="color: #ff0000;">List Item Not Found</span> message. Unfortunately, it&#8217;s very difficult to get any information other than what&#8217;s in the workflow history log. I attempted to read through the operations logs as well, but the information wasn&#8217;t really too helpful.</p>
<p>Doing some basic troubleshooting by adding an email activity and outputting the lookup variables in the body helped me determine that the <strong>Customer</strong> column in the <strong>Survey</strong> list was returning a blank value. That&#8217;s strange. Adding, editing and displaying items in the Customer list gives me no issue, I can select customers from my lookup and they read just fine. So why the heck does my workflow not properly record this value?</p>
<p>It gets a bit more puzzling when I grant myself <strong>Site Collection Administrator</strong> access to my site. Now all of a sudden, the workflow works and the lookup executes without issue. My entry in the Customers list is updated, all is happy for once. But granting users <strong>Site Collection Administration</strong> access is not a viable solution. It&#8217;s actually pretty crazy, so that&#8217;s not going to happen.</p>
<p>So after much frustration, I am sorry to report I don&#8217;t have much new information. What I did attempt to do however, was build my own version of the <strong>Update List Item</strong> activity in <strong>Visual Studio 2008</strong>. That turned out to be relatively straight forward. I used a bit of reflector to get the bits that I needed to successfully write this. That gave me the debugging capabilities that I desperately needed.</p>
<p>What I was now able to see with my custom activity was that the <strong>ListItem</strong> property was returning <strong>-1</strong>, and thus the <strong>GetItemById</strong> call on the <strong>Customers</strong> list was unable to find the item. Now why in the world was it returning <strong>-1</strong>? I&#8217;m still puzzled by this, and I&#8217;m not 100% sure if this is indeed a permissions related problem or if it&#8217;s something a entirely different.</p>
<p>I&#8217;m opening this up to anyone out there who might have some information regarding this particular issue. In the end, I wrote a custom Visual Studio sequential workflow, with literally 5 or so lines of code that essentially does the update for me and that runs without issue. I didn&#8217;t want to have to do that, but it was the only option I was left with for this particular list.</p>
<p>If anyone has any info, please drop me a line @ shereen at qumsieh dot ca. I would LOVE to get to the bottom of this.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.qumsieh.ca/2009/10/08/sharepoint-designer-custom-workflow-list-item-not-found/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom SharePoint Workflows sendEmail.Body Character Limit</title>
		<link>http://blog.qumsieh.ca/2009/07/09/custom-sharepoint-workflows-sendemailbody-character-limit/</link>
		<comments>http://blog.qumsieh.ca/2009/07/09/custom-sharepoint-workflows-sendemailbody-character-limit/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 00:04:59 +0000</pubDate>
		<dc:creator>shereen</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Workflows]]></category>

		<guid isPermaLink="false">http://blog.qumsieh.ca/?p=457</guid>
		<description><![CDATA[I&#8217;ve been working over the past few days with a custom workflow I&#8217;m building in Visual Studio 2005 that&#8217;s responsible for notifying users when specific criteria was met. Inside the workflow, I have a few sendEmail functions responsible for building the content within the email message: 1 2 sendEmail1.Body += &#34;&#60;font face=\&#34;Arial\&#34;&#62;This is the body [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working over the past few days with a custom workflow I&#8217;m building in Visual Studio 2005 that&#8217;s responsible for notifying users when specific criteria was met. Inside the workflow, I have a few <strong>sendEmail</strong> functions responsible for building the content within the email message:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">sendEmail1.<span style="color: #0000FF;">Body</span> <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;&lt;font face=<span style="color: #008080; font-weight: bold;">\&quot;</span>Arial<span style="color: #008080; font-weight: bold;">\&quot;</span>&gt;This is the body of my email.&lt;br/&gt;&lt;br/&gt;&quot;</span><span style="color: #008000;">;</span>
sendEmail1.<span style="color: #0000FF;">Body</span> <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;Adding some information for users that will describe some detail about this item.&lt;/font&gt;&quot;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>The above worked well until I started to see some truncating in my emails. I did some comparisons and found that the truncating would occur when the character count exceeded 2048 characters. I figured this couldn&#8217;t be the limit for a string in .NET so I did a bit of digging around and finally discovered that the root of the issue was because I didn&#8217;t have any line breaks in my string: <strong>&#8220;\r\n&#8221;</strong>. Once I inserted those at specific intervals, the truncating disappeared.</p>
<p>Awesome! Hope this helps someone else out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.qumsieh.ca/2009/07/09/custom-sharepoint-workflows-sendemailbody-character-limit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To Programmatically Trigger a Custom Workflow</title>
		<link>http://blog.qumsieh.ca/2009/07/08/how-to-programmatically-trigger-a-custom-workflow/</link>
		<comments>http://blog.qumsieh.ca/2009/07/08/how-to-programmatically-trigger-a-custom-workflow/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 18:24:51 +0000</pubDate>
		<dc:creator>shereen</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Workflows]]></category>

		<guid isPermaLink="false">http://blog.qumsieh.ca/?p=450</guid>
		<description><![CDATA[Triggering SharePoint workflows programmatically from within a custom built Visual Studio workflow is not difficult once you know where to look. Tony Testa wrote a great post on this very same thing that describes these concepts in more detail than I will &#8212; so go check that out if you haven&#8217;t already. I had to [...]]]></description>
			<content:encoded><![CDATA[<p>Triggering SharePoint workflows programmatically from within a custom built Visual Studio workflow is not difficult once you know where to look. Tony Testa wrote a <a href="http://www.tonytestasworld.com/post/Howto-Start-a-Sharepoint-Workflow-Programmatically.aspx">great post</a> on this very same thing that describes these concepts in more detail than I will &#8212; so go check that out if you haven&#8217;t already. I had to tweak his concept a little bit because I was doing this within an already running workflow that belonged to a content type not a list. </p>
<p>So in my scenario, I had a single workflow tied to a Content Type, and because I knew there was only one workflow, I used index at 0 to get the current workflow association. If your workflow is tied to a list, then you may not need to call <strong>ContentType</strong>, you might be able to use:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">SPWorkflowAssociation workflowAssociation <span style="color: #008000;">=</span> workflowProperties.<span style="color: #0000FF;">List</span>.<span style="color: #0000FF;">WorkflowAssocations</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>If you have multiple workflows tied to a Content Type or a List, you will need to grab the Guid associationId for that workflow instead of using the index.</p>
<p>Finally, once I have my workflow association configured, I can start my workflow by passing it the parameters it needs:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>workflowProperties.<span style="color: #0000FF;">Site</span>.<span style="color: #0000FF;">WorkflowManager</span>.<span style="color: #0000FF;">GetItemActiveWorkflows</span><span style="color: #000000;">&#40;</span>setLeaderItem<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    SPWorkflowAssociation workflowAssociation <span style="color: #008000;">=</span> workflowProperties.<span style="color: #0000FF;">Item</span>.<span style="color: #0000FF;">ContentType</span>.<span style="color: #0000FF;">WorkflowAssociations</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
    workflowProperties.<span style="color: #0000FF;">Site</span>.<span style="color: #0000FF;">WorkflowManager</span>.<span style="color: #0000FF;">StartWorkflow</span><span style="color: #000000;">&#40;</span>setLeaderItem, workflowAssociation, workflowAssociation.<span style="color: #0000FF;">AssociationData</span>, <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>The IF block is there to check if any active workflow are running on that list item. If there aren&#8217;t, it attempts to start the workflow. There you have it! That should trigger the workflow on the list item you specified.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.qumsieh.ca/2009/07/08/how-to-programmatically-trigger-a-custom-workflow/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fetching the Display Name Within a Custom Workflow</title>
		<link>http://blog.qumsieh.ca/2008/01/30/fetching-the-display-name-from-a-login-name-within-a-custom-workflow/</link>
		<comments>http://blog.qumsieh.ca/2008/01/30/fetching-the-display-name-from-a-login-name-within-a-custom-workflow/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 00:07:05 +0000</pubDate>
		<dc:creator>shereen</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Object Model]]></category>
		<category><![CDATA[Workflows]]></category>

		<guid isPermaLink="false">http://blog.qumsieh.ca/?p=31</guid>
		<description><![CDATA[If you&#8217;re working with custom workflows, and you&#8217;ve run into a scenario where you have the login name of the user in the form of domain\juser but would like to see a more user friendly display name like Joe User then here&#8217;s how you do it: What I usually do is create an SPUser object [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re working with custom workflows, and you&#8217;ve run into a scenario where you have the login name of the user in the form of <strong>domain\juser</strong> but would like to see a more user friendly display name like <strong>Joe User</strong> then here&#8217;s how you do it:</p>
<p>What I usually do is create an SPUser object and then use the Name property to get at the display name of the user. Once I&#8217;ve got an SPUser object created, I have access to several different properties and methods. You can view the full list on msdn. The SiteUsers property will take in a string containing the login name of the user</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">SPUser user <span style="color: #008000;">=</span> workflowProperties.<span style="color: #0000FF;">web</span>.<span style="color: #0000FF;">SiteUsers</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;">string</span> loginName<span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
<span style="color: #FF0000;">string</span> fullName <span style="color: #008000;">=</span> user.<span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.qumsieh.ca/2008/01/30/fetching-the-display-name-from-a-login-name-within-a-custom-workflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

