<?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] : Enterprise Search, WebPart, SharePoint</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Enterprise+Search/WebPart/SharePoint/default.aspx</link><description>Tags: Enterprise Search, WebPart, SharePoint</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Using search to find recently modified files in SharePoint 2010</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/12/08/using-search-to-find-recently-modified-files-in-sharepoint-2010.aspx</link><pubDate>Thu, 08 Dec 2011 20:15:24 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:5364</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>9</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=5364</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/12/08/using-search-to-find-recently-modified-files-in-sharepoint-2010.aspx#comments</comments><description>&lt;p&gt;Last week, I posted about how we can extend &lt;em&gt;CoreResultsWebPart&lt;/em&gt; to show documents created by the current user.&amp;#160; Using this same technique, we can also use search to find recently modified documents.&amp;#160; If you are a long time follower of my blog, you might remember that I posted how to do with using the &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/09/17/using-wildcard-search-web-part-to-search-for-recently-modified-files.aspx"&gt;Wildcard Search Web Part&lt;/a&gt; in SharePoint 2007.&amp;#160; In an effort to keep posts updated, I thought I would post a follow up on how we can do the same thing in SharePoint 2010.&amp;#160; Since the &lt;em&gt;CoreResultWebPart &lt;/em&gt;has changed quite a bit, the solution is quite a bit cleaner and still only requires two lines of code.&amp;#160; Again, we are going to create a web part that inherits from &lt;em&gt;CoreResultsWebPart &lt;/em&gt;as described in my &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/05/13/wildcard-search-web-part-for-sharepoint-2010.aspx"&gt;Wildcard Search Web Part for SharePoint 2010&lt;/a&gt; post.&amp;#160; &lt;/p&gt;  &lt;p&gt;The first thing we need to do is change the &lt;em&gt;QueryNumber&lt;/em&gt;.&amp;#160; By default it is set to &lt;em&gt;Query1&lt;/em&gt; (or &lt;em&gt;UserQuery&lt;/em&gt; back in 2007) which meant that it was expecting input from the user.&amp;#160; In this case, I just change it to &lt;em&gt;Query2&lt;/em&gt;.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;this&lt;/span&gt;.QueryNumber = &lt;span style="color:#2b91af;"&gt;QueryId&lt;/span&gt;.Query2;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Then we just need to construct a query using the &lt;em&gt;Write&lt;/em&gt; keyword.&amp;#160; I’ve explained its use before in my &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/07/20/some-handy-keywords-you-might-find-useful-in-sharepoint-enterprise-search.aspx"&gt;handy keywords&lt;/a&gt; post.&amp;#160; It’s syntax is usually something like this.&amp;#160; Note that there are no spaces anywhere in the string below.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Write&amp;gt;=”12/1/2011”&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Of course this would hard code the date and we don’t want that.&amp;#160; So what I do instead is use DateAdd and subtract a number of days.&amp;#160; In my case, I want to show all documents from the last seven days.&amp;#160; We assign this query to the &lt;em&gt;FixedQuery&lt;/em&gt; property.&amp;#160; Here is what it looks like.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;this&lt;/span&gt;.FixedQuery = &lt;span style="color:blue;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515;"&gt;&amp;quot;Write&amp;gt;=\&amp;quot;{0}\&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt;.Today.AddDays(-7));&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Compile your code and deploy it and then you are good to go.&amp;#160; Just use this web part in lieu of the regular&lt;em&gt;CoreResultsWebPart&lt;/em&gt;.&amp;#160; Here’s what it looks like on my page.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SearchRecentDocuments_11FC15E4.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SearchRecentDocuments" border="0" alt="SearchRecentDocuments" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SearchRecentDocuments_thumb_714464CA.png" width="532" height="404" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s all there is to it.&amp;#160; One addition, you might want to make to your code is to allow the number of days to be user configurable.&amp;#160; You can easily make a web part property that allows the user to specify the number of days.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=5364" 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/Enterprise+Search/default.aspx">Enterprise Search</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category></item></channel></rss>