<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.dotnetmafia.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>Corey Roth [MVP] : Records Center</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Records+Center/default.aspx</link><description>Tags: Records Center</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Handling ShortTerm CheckOut Locks in your Records Center Workflow</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/01/29/handling-shortterm-checkout-locks-in-your-records-center-workflow.aspx</link><pubDate>Thu, 29 Jan 2009 20:39:20 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:830</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=830</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/01/29/handling-shortterm-checkout-locks-in-your-records-center-workflow.aspx#comments</comments><description>&lt;p&gt;The other day, I posted about how to write a simple workflow to copy files to the records center whenever they were created or modified.&amp;nbsp; Well the workflow I provided worked in all of the following cases.&lt;/p&gt; &lt;ul&gt; &lt;li class="MsoNormal" style="margin:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Tahoma&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;Add new item&lt;/span&gt;&lt;/li&gt; &lt;li class="MsoNormal" style="margin:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Tahoma&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;Upload Item&lt;/span&gt;&lt;/li&gt; &lt;li class="MsoNormal" style="margin:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Tahoma&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;Upload new version to existing item&lt;/span&gt;&lt;/li&gt; &lt;li class="MsoNormal" style="margin:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Tahoma&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;manual check out then check back in (with no changes to the doc.)&lt;/span&gt;&lt;/li&gt; &lt;li class="MsoNormal" style="margin:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Tahoma&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;Edit document properties (When checkout required is set on the library)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Of course there was one place that I found that it doesn&amp;#39;t work.&amp;nbsp; It is when you use the New Document button or edit an existing document directly with Office 2007.&amp;nbsp; The reason for this is that when you have a document open with Office, it creates a Short Term Check Out for the period of an hour.&amp;nbsp; It also continues to reestablish the lock until you close the Office application (i.e.: Microsoft Word).&amp;nbsp; Records Center will not accept any document that is currently checked out.&amp;nbsp; This presented an interesting challenge on how to deal with this.&amp;nbsp; The first thing I tried was adding code to check in the file (i.e.: SPFile.CheckIn).&amp;nbsp; This method does not work when the CheckOutType is &lt;em&gt;ShortTerm&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;I tried an ItemEventReceiver to see if closing Office would trigger the ItemCheckedIn event, but it in fact does not.&amp;nbsp; This means I can&amp;#39;t handle this scenario that way either.&amp;nbsp; So what I came up with was a hack, but it does in fact get the job done (provided the user eventually closes the Office application).&amp;nbsp; Here is what it looks like.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WindowsLiveWriter/HandlingShortTermCheckOutLocksinyourReco_CA86/RecordsCenterWorkflow2_2.jpg"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="286" alt="RecordsCenterWorkflow2" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WindowsLiveWriter/HandlingShortTermCheckOutLocksinyourReco_CA86/RecordsCenterWorkflow2_thumb.jpg" width="170" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;I did say hack, didn&amp;#39;t I?&amp;nbsp; That&amp;#39;s exactly what it is.&amp;nbsp; The While activity contains the following code condition.&amp;nbsp; All it does it execute the contents of the while activity as long as the &lt;em&gt;CheckOutStatus&lt;/em&gt; is set to &lt;em&gt;ShortTerm&lt;/em&gt; (meaning the user still has Microsoft Word open).&lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; IsShortTermCheckedOut(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, ConditionalEventArgs e)&lt;/p&gt; &lt;p style="margin:0px;"&gt;{&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.Result = (workflowProperties.Item.File.CheckOutStatus == SPFile.SPCheckOutStatus.ShortTerm);&lt;/p&gt; &lt;p style="margin:0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;p&gt;As you can see there is a Delay activity in there.&amp;nbsp; These actually seem to work now, but you do need to be sure that you have the latest version of the .NET Framework installed as well as all updates applied to SharePoint.&amp;nbsp; Otherwise there is a good chance that your workflow will never wake back up.&amp;nbsp; I have the delay set to 15 minutes.&amp;nbsp; This is because the workflow timer job runs every 15 minutes (by default).&lt;/p&gt; &lt;p&gt;Other than that the code is all the same from the previous post.&amp;nbsp; I&amp;#39;ve ran it through several tests and it seems to work for me.&amp;nbsp; I&amp;#39;d like to think there is a better way to handle this, but I can&amp;#39;t think of anything right now.&amp;nbsp; You might consider adding code to the while activity so that it eventually terminates if the user never closes Office, but that is up to you.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=830" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Workflow/default.aspx">Workflow</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Records+Center/default.aspx">Records Center</category></item></channel></rss>