<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>rakhiguha</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/rakhiguha/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/rakhiguha/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:25:19 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Resolution for Sharepoint Document ID Issue with Metalogix Migration</title>
      <link>https://docs.microsoft.com/archive/blogs/rakhiguha/resolution-for-sharepoint-document-id-issue-with-metalogix-migration</link>
      <pubDate>Fri, 17 Feb 2017 10:46:43 GMT</pubDate>
      <dc:creator><![CDATA[rakhiguha]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rakhiguha/?p=175</guid>
      <description><![CDATA[Metalogix is a widely-used migration tool specially when we need to migrate content in large scale....]]></description>
      <content:encoded><![CDATA[Metalogix is a widely-used migration tool specially when we need to migrate content in large scale. But the fact cannot be denied that it comes with some known limitation/issue as well. Sometimes we don’t even have any idea what went wrong in a specific scenario. One of such case is while migrating Document workspace sites, often we end up with document url suffixed with source url. As a result, due to inappropriate document url we face issues with sharing feature. Even attempt to open the document will lead to error page.

It is an intermittent issue but when it occurs, it leads to customer escalation L. After doing a lot of investigation although we could not find the reason for this issue, but we have a resolution to remediate this. We can use the share point document id regeneration to resolve.

<strong><u>Process to Re Generate the Document ID</u></strong>
<ol>
 	<li>Ensure Document ID Service Feature is activated on the Target sites</li>
</ol>
Go to Site Settings &gt; Site Collection Administration &gt; Site Collection Feature and Ensure Document ID Service feature is activated

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2017/02/Untitled4.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/02/Untitled4.png" alt="untitled" width="1058" height="500" class="alignnone size-full wp-image-245" /></a>2. Go to Site Settings &gt; Site Collection Administration &gt; Document ID Settings

<a href="https://msdnshared.blob.core.windows.net/media/2017/02/Untitled5.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/02/Untitled5.png" alt="untitled" width="709" height="444" class="alignnone size-full wp-image-255" /></a>

3.   Click on Document ID Settings link and go to the Document ID Settings Page. Provide the inputs as shown below, ensure the <strong>Begin IDs with the following characters</strong> settings should comply the constrains
<ul>
 	<li>Should not be left empty</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2017/02/Untitled6.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/02/Untitled6.png" alt="untitled" width="712" height="314" class="alignnone size-full wp-image-265" /></a>
<ul>
 	<li>Must be 4 to 12 character long</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2017/02/Untitled7.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/02/Untitled7.png" alt="untitled" width="712" height="314" class="alignnone size-full wp-image-275" /></a>
<ul>
 	<li>Click on ok. If we re navigate to the same page it will comes up with the following message and it will stay till the process completed</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2017/02/Untitled8.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/02/Untitled8.png" alt="untitled" width="622" height="156" class="alignnone size-full wp-image-276" /></a>
<ul>
 	<li>It will take some time and once it is completed the document ID will be regenerated with appropriate target url and the Document ID will contain the Phrase provided in the <strong>Begin IDs with the following characters</strong></li>
</ul>
&nbsp;

<strong>Note: In case we need to have an urgent fix for this issue, we have a quick workaround. If we do a check out of the document followed by undo/discard checkout, the document url issue will get resolved.</strong>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Enable Ribbon on item selection in SharePoint 2013</title>
      <link>https://docs.microsoft.com/archive/blogs/rakhiguha/enable-ribbon-on-item-selection-in-sharepoint-2013</link>
      <pubDate>Tue, 20 Sep 2016 07:05:11 GMT</pubDate>
      <dc:creator><![CDATA[rakhiguha]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rakhiguha/?p=155</guid>
      <description><![CDATA[With every version of SharePoint Microsoft changes a lot that its hard to adjust with new version....]]></description>
      <content:encoded><![CDATA[With every version of SharePoint Microsoft changes a lot that its hard to adjust with new version. It takes bit of time to get used to the new changes in new version. Just an example In SharePoint 2007 the Site Actions menu was in the right corner of the screen, in SharePoint 2010 the Site Actions moved to left of the screen, again in SharePoint 2013 the Site Actions(gear icon) is moved to the right corner of the screen.

In SharePoint 2010 the ribbon is by default selected when an item is selected, but in SharePoint 2013 the ribbon is not selected by default. So I tried hard to find a setting which can help in enabling the ribbon by default. But no luck. Tried searching a lot but didn't find a direct way to do so. Here in this article I will help you in enabling the ribbon when selecting an item in SharePoint 2013.

<strong>Why by default the ribbon is not selected in SharePoint 2013</strong>

The new UI reflects their “Minimal Download Strategy” in SharePoint 2013 that improves rendering performance when browsing content where large parts of the page do not change, which provides a more fluid navigation experience.

Now the question is <span><b>How Ribbon can be enabled</b></span> ?

<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">// JavaScript source code</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">
</span><span></span><span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">function ShowItemsMenuWhenItemsSelected() {</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">    var oldToggleItemRowSelection = ToggleItemRowSelection;</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">    ToggleItemRowSelection = function (ctxCur, tr, fSelect, a, b) {</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">        oldToggleItemRowSelection(ctxCur, tr, fSelect, a, b)</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">        </span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">        if ((ctxCur.CurrentSelectedItems &gt; 0) &amp;&amp; (ctxCur.listBaseType == 0) &amp;&amp; (ctxCur.ListTemplateType == 171)) {</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">            SelectRibbonTab("Ribbon.Tasks", true);  //open the ribbon for tasks list</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">        }</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">        else if ((ctxCur.CurrentSelectedItems &gt; 0) &amp;&amp; (ctxCur.listBaseType == 1)) {</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">            SelectRibbonTab("Ribbon.Document", true);  //open the ribbon for Documents Library</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">        }</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">        else if (ctxCur.CurrentSelectedItems &gt; 0) {</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">            if ((ctxCur.listBaseType == 0) || (ctxCur.listBaseType == 5))</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">            {</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">                SelectRibbonTab("Ribbon.ListItem", true);  //open the ribbon for List items</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">            }</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">        }</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">        else {</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">            SelectRibbonTab("Ribbon.Read", true);  //close the ribbon</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">        }</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">    }</span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">} </span>
<span style="color: #222222;font-size: 13.2px;font-style: normal;font-weight: normal;letter-spacing: normal;line-height: 18.48px;text-align: left;text-indent: 0px;font-family: 'Courier New', Courier, monospace;background-color: #ffffff">_spBodyOnLoadFunctionNames.push("ShowItemsMenuWhenItemsSelected");</span>]]></content:encoded>
    </item>
    <item>
      <title>SharePoint 2013 Global Navigation wrap up</title>
      <link>https://docs.microsoft.com/archive/blogs/rakhiguha/sharepoint-2013-global-navigation-wrap-up</link>
      <pubDate>Tue, 20 Sep 2016 06:50:24 GMT</pubDate>
      <dc:creator><![CDATA[rakhiguha]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rakhiguha/?p=135</guid>
      <description><![CDATA[In SharePoint 2013 if number of links in the global navigation increases, the links are not wrapped...]]></description>
      <content:encoded><![CDATA[<div><span>In SharePoint 2013 if number of links in the global navigation increases, the links are not wrapped by default. The links are aligned in single line. Sometimes the links are more in number that people started complaining about search bar is not available even though the search bar is available in the right corner of the page. Users never realized the horizontal bar at the bottom of the page. If we scroll to the right corner of the page we can see the search bar. Talking about user experience this looks very weird. </span>
<span></span></div>
<div><span>After some trial CSS tricks appeared to rescue us.
</span><span>Some of the css classes needs to be modified which will help in wrapping the global navigation in SharePoint 2013. Below are the examples which can be used:-</span>
<span>
</span><span>.ms-core-pageTitle{</span>
<span>    font-size:2em;</span>
<span>}</span>
<span>.ms-core-listMenu-horizontalBox ul, .ms-core-listMenu-horizontalBox li, .ms-core-listMenu-horizontalBox </span>
<span>.ms-core-listMenu-item, .ms-core-listMenu-horizontalBox &gt; ul &gt; li &gt; table</span>
<span>{</span>
<span>    display :inline !important;</span>
<span>}</span>
<span>.ms-core-listMenu-horizontalBox</span>
<span>{</span>
<span>    display:inline !important;</span>
<span>}</span>
<span>#s4-titlerow{</span>
<span>    height:inherit !important;</span>
<span>}</span>
<span>
</span><span>.ms-breadcrumb-top</span>
<span>{</span>
<span>    white-space:normal !important;</span>
<span>    border-bottom:medium;</span>
<span>    border-bottom-width:1px;</span>
<span>    padding-bottom: 10px;</span>
<span>    font-weight:bold;</span>
<span>}</span>
<span>.ms-core-listMenu-horizontalBox .additional-background.dynamic-children{</span>
<span>    padding-bottom:26px;</span>
<span>    background-position:center;</span>
<span>    display:inline !important;</span>
<span>}</span>
<span>ul.dynamic {</span>
<span>    background-color:#ECEBEB !important;</span>
<span>    display:inline-block !important;</span>
<span>    font-weight:normal;</span>
<span>    padding:3px,10px;</span>
<span>}</span>
<span>li.dynamic .menu-item-text  {</span>
<span>    display:inline-block !important;</span>
<span>    padding-bottom: 10px;</span>
<span>    padding-right:0px;</span>
<span>    background-repeat:no-repeat;</span>
<span>    background-position : bottom,center !important;</span>
<span>    color:black !important;</span>
<span></span>
<span>}</span></div>
<div></div>
<div><span>Hope this helps in resolving the issue you are facing. </span></div>]]></content:encoded>
    </item>
    <item>
      <title>Manage Permission Level at subsites using powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/rakhiguha/manage-permission-level-at-subsites-using-powershell</link>
      <pubDate>Tue, 08 Dec 2015 03:03:48 GMT</pubDate>
      <dc:creator><![CDATA[rakhiguha]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rakhiguha/2015/12/08/manage-permission-level-at-subsites-using-powershell/</guid>
      <description><![CDATA[In SharePoint 2010 the manage permission levels options by default do not appear on the screen. If...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: arial, helvetica, sans-serif;">In SharePoint 2010 the manage permission levels options by default do not appear on the screen. If we navigate to the manage permission page for a subsite it will appear as given below</span></p>
<p><span style="font-family: arial, helvetica, sans-serif;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/8867.Untitled.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/8867.Untitled.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/8867.Untitled.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/8867.Untitled.png" alt="" border="0" /></a></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-family: arial, helvetica, sans-serif;">Hence if we want to change or modify any permission level we will required to do so from parent site. This can be hacked using a very simple two line of powershell script.</span></p>
<p>$web = Get-SPWeb &ldquo;&lt;Sub site url on which the inheritance need to be broken&gt;"</p>
<p>$web.RoleDefinitions.BreakInheritance($true,$true)</p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">This two line of code need to be executed from the sharepoint WFE server. Once this is done user can see the below links on browser and free to do any changes on permission level for that sub site</span></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/2330.Untitled.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/2330.Untitled.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/2330.Untitled.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/2330.Untitled.png" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>CSOM Sharepoint sites Change Log</title>
      <link>https://docs.microsoft.com/archive/blogs/rakhiguha/csom-sharepoint-sites-change-log</link>
      <pubDate>Mon, 07 Dec 2015 23:22:00 GMT</pubDate>
      <dc:creator><![CDATA[rakhiguha]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rakhiguha/2015/12/07/csom-sharepoint-sites-change-log/</guid>
      <description><![CDATA[Very often we need to gather information on SharePoint site/web changes after a specific period....]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">Very often we need to gather information on SharePoint site/web changes after a specific period. Specially We found it very useful to trace any modification done on a site post migration and in case incremental job to be run one can easily identify what are the new changes will be lost after the migration.</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">In order to do so we need to do the following</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">To gather the site level changes&nbsp;</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">Initialize the below variables as required.</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">Site rootSite;</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">ClientContext context;</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">DateTime dateTime;</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">string format = "1;1;{0};{1};-1";</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">ChangeQuery cq = new ChangeQuery(true, true);</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">cq.ChangeTokenStart = new ChangeToken()</span></p>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> {</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> StringValue = string.Format(format, rootSite.Id, dateTime.Ticks)</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> };</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> ChangeCollection changeCol = rootSite.GetChanges(cq);</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">context.Load(changeCol);</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;">context.ExecuteQuery();</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> while (changeCol.Count &gt; 0)</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> {</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">//DO THE PROCESSING TO GATHER ALL THE REQUIRED INFO LIKE SITE NAME, ID, CHANGW TYPE etc.</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> }</span></pre>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">At we level the process is same instead of Site instance we need to consider the instance of a specific WEB.</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">Different type of changes that can be gathered using the above approach are listed below, all are Out of the box .NET classes available under the Microsoft.SharePoint.Client namsespace</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">1.ChangeSite</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">2.ChangeItem</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">3.ChangeField</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">4.ChangeList</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">5.ChangeFolder</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">6.ChangeView</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">7.ChangeWeb</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">8.ChangeContentType</span></p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Migrate Sharepoint document with version to Sharepoint online using CSOM</title>
      <link>https://docs.microsoft.com/archive/blogs/rakhiguha/migrate-sharepoint-document-with-version-to-sharepoint-online-using-csom</link>
      <pubDate>Sun, 06 Dec 2015 21:03:00 GMT</pubDate>
      <dc:creator><![CDATA[rakhiguha]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rakhiguha/2015/12/06/migrate-sharepoint-document-with-version-to-sharepoint-online-using-csom/</guid>
      <description><![CDATA[It has been observed quite &nbsp;a few time that METALOGIX failed to migrate large document library...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">It has been observed quite &nbsp;a few time that METALOGIX failed to migrate large document library content with version enabled or library using managed metadata. Very often it gets timed out exception during the operation.</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">To overcome this issue in one of our migration project we used CSOM to migrate the documents with versions.</span></p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">Using the following code piece we can migrate the documents with their version from one platform to the other one.</span></p>
<p>&nbsp;</p>
<p><span style="font-size: small; font-family: arial, helvetica, sans-serif;">1. Prepare the source and target client context here I am assuming target is sharepoint online</span></p>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> ServicePointManager.ServerCertificateValidationCallback += customXertificateValidation;</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> ClientContext sourceContext = new ClientContext(sourceSiteUrl);</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> sourceContext.Credentials = new NetworkCredential(sourceUserName, sourcePassWord, sourceDomain);</span></pre>
<pre><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> ClientContext targetContext = new ClientContext(targetSiteUrl);</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> var passWord = new SecureString();</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> foreach (char c in targetPassWord.ToCharArray()) passWord.AppendChar(c);</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> targetContext.Credentials = new SharePointOnlineCredentials(targetUserName, passWord);</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">2. Get the source folder</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> Folder sourceFolder = sourceContext.Web.GetFolderByServerRelativeUrl(sourceFolderUrl); </span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> sourceContext.Load(sourceFolder, fldr =&gt; fldr.Name);</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> sourceContext.Load(sourceFolder.Files, files =&gt; files.Include(</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> file =&gt; file.ListItemAllFields</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> ));</span><br /><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> try</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> {</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> sourceContext.ExecuteQuery();</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> }</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> catch (Exception e)</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> {</span><br />              <br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> }</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">3. Get the target folder</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> Folder targetSiteFolder = targetContext.Web.GetFolderByServerRelativeUrl(targetFolderUrl);</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> targetContext.Load(targetSiteFolder.Files, files =&gt; files.Include(</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> file =&gt; file.ListItemAllFields</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> ));</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> targetContext.Load(targetSiteFolder);</span><br /><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> try</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> {</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> targetContext.ExecuteQuery();</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> }</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> catch (Exception ex)</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> {</span><br />                <br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> }</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">4. Do the migration operation</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">&nbsp;int fileCount = sourceFolder.Files.Count();</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">for (int i = 0; i &lt; fileCount; i++)</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> {</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> Microsoft.SharePoint.Client.File sourceFile = sourceFolder.Files[i];</span></pre>
<pre id="pre582777"><span style="font-size: small; font-family: arial, helvetica, sans-serif;">FileVersionCollection sourceFileVersions = sFile.Versions; sContext.Load(sourceFileVersions, fileVersions =&gt; fileVersions.Include( version =&gt; version.Url, version =&gt; version.VersionLabel, version =&gt; version.CheckInComment )); <span class="code-keyword">try</span> { sContext.ExecuteQuery(); } <span class="code-keyword">catch</span> (Exception e) { <span class="code-comment">//</span><span class="code-comment">handle exception </span> &nbsp;</span></pre>
<pre id="pre582777"><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> }</span></pre>
<pre id="pre118302"><span style="font-size: small; font-family: arial, helvetica, sans-serif;"><span class="code-keyword">foreach</span> (FileVersion fileVer <span class="code-keyword">in</span> sourceFileVersions)</span></pre>
<pre id="pre118302"><span style="font-size: small; font-family: arial, helvetica, sans-serif;">{ UploadFiles(sContext.Url + <span class="code-string">"</span><span class="code-string">/"</span> + fileVer.Url, targetFolder, sourceItem[<span class="code-string">"</span><span class="code-string">FileLeafRef"</span>].ToString());</span></pre>
<pre id="pre118302"><span style="font-size: small; font-family: arial, helvetica, sans-serif;">}</span></pre>
<pre id="pre118302"><span style="font-size: small; font-family: arial, helvetica, sans-serif;">}</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">5.</span></pre>
<pre id="pre405658"><span style="font-size: small; font-family: arial, helvetica, sans-serif;"><span class="code-keyword">private</span> <span class="code-keyword">static</span> <span class="code-keyword">void</span> UploadFiles(<span class="code-keyword">string</span> sourceFileUrl, Folder targetFolder, <span class="code-keyword">string</span> fileName)</span></pre>
<pre id="pre405658"><span style="font-size: small; font-family: arial, helvetica, sans-serif;">&nbsp;{</span></pre>
<pre id="pre405658"><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> FileCreationInformation targetFileVersionCreationInfo = <span class="code-keyword">new</span> FileCreationInformation(); targetFileVersionCreationInfo.Overwrite = <span class="code-keyword">true</span>; <span class="code-keyword">try</span> { WebRequest request = HttpWebRequest.Create(sourceFileUrl); request.Credentials = sContext.Credentials; <span class="code-keyword">using</span> (WebResponse response = request.GetResponse()) { <span class="code-keyword">using</span> (Stream stream = response.GetResponseStream()) { <span class="code-keyword">byte</span>[] verBuffer = <span class="code-keyword">new</span> <span class="code-keyword">byte</span>[<span class="code-digit">32768</span>]; <span class="code-keyword">using</span> (MemoryStream versionMS = <span class="code-keyword">new</span> MemoryStream()) { <span class="code-keyword">int</span> read; <span class="code-keyword">while</span> ((read = stream.Read(verBuffer, <span class="code-digit">0</span>, verBuffer.Length)) &gt; <span class="code-digit">0</span>) { versionMS.Write(verBuffer, <span class="code-digit">0</span>, read); } versionMS.Seek(<span class="code-digit">0</span>, SeekOrigin.Begin); targetFileVersionCreationInfo.ContentStream = versionMS; tContext.RequestTimeout = System.Threading.Timeout.Infinite; targetFileVersionCreationInfo.Url = targetFolder.ServerRelativeUrl + <span class="code-string">"</span><span class="code-string">/"</span> + fileName; Microsoft.SharePoint.Client.File targetVersionFile = targetFolder.Files.Add(targetFileVersionCreationInfo); <span class="code-keyword">try</span> { tContext.ExecuteQuery(); } <span class="code-keyword">catch</span> (Exception ex) { <span class="code-comment">//</span><span class="code-comment">handle exception </span> &nbsp;</span></pre>
<pre id="pre405658"><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> } } } } } <span class="code-keyword">catch</span> (Exception ex) { <span class="code-comment">//</span><span class="code-comment">handle exception </span> &nbsp;</span></pre>
<pre id="pre405658"><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> }</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> }</span></pre>
<pre>&nbsp;</pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">The above piece of code is able to migrate the document with version but it has few issues&nbsp;</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"><strong>Issue 1</strong>. The created date,modified date,credated by and modified by field will be changed to keep these field intact we need to do the following</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> List list = targetContext.Web.Lists.GetByTitle(fldr.Name);</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> ListItem item = file.ListItemAllFields;</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> targetContext.Load(list, listObject =&gt; listObject.EnableVersioning, listObject =&gt; listObject.EnableMinorVersions);</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> targetContext.Load(item, itemObject =&gt; itemObject.File);</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> targetContext.ExecuteQuery(); </span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> [PLACEHOLDER 1] </span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> targetContext.ExecuteQuery();</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> FieldUserValue targetCreatedUser = new FieldUserValue();</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> targetCreatedUser.LookupId = createdUser.Id;</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> FieldUserValue targetModifiedUser = new FieldUserValue();</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> targetModifiedUser.LookupId = modifieddUser.Id; </span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> item["Editor"] = targetModifiedUser;</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> item["Author"] = targetCreatedUser;</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> item["Created"] = created;</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> item["Modified"] = modified;</span><br /><br /><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> item.Update(); </span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> [PLACEHOLDER 2] </span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> targetContext.ExecuteQuery();</span></pre>
<pre><span style="font-family: arial, helvetica, sans-serif;"><strong style="font-size: small;">Issue 2</strong><span style="font-size: x-small;">:<span style="font-size: small;"> In attempt to keep the created and modified information intact the code internally create additional version as the library is enabled with version changes.</span></span></span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">To resolvethat we need to put the following code in PLACEHOLDER1 and PLACEHOLDER 2 subsequently</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">PLACEHOLDER1</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> var isVersionEnable = list.EnableVersioning;</span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> list.EnableVersioning = false; </span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> list.Update(); </span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">PLACEHOLDER 2 </span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> list.EnableVersioning = true; </span><br /><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> list.Update(); </span></pre>
<pre>&nbsp;</pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"><strong>Issue 3: </strong>With the above fixes we are done with migrating documents with versions for the libraries which are version enabled and Forcecheckout checkin option set as false.</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;"> If the library is configured for Forcechecckout then with the above piece of code execution we will be end up with documents with latest version all the previous version info will not be available. To overcome this issue we need to do a small hack before staring actual migration code.</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">We need to set the forcecheckout option for the target library as false.</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">&nbsp; targetList.ForceCheckout = false;</span></pre>
<pre><span style="font-size: small; font-family: arial, helvetica, sans-serif;">and at the end of migrating all the doc just set it back with actual settings.</span></pre>]]></content:encoded>
    </item>
    <item>
      <title>Sharepoint User Profile context Filter webpart using powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/rakhiguha/sharepoint-user-profile-context-filter-webpart-using-powershell</link>
      <pubDate>Tue, 06 Oct 2015 02:28:00 GMT</pubDate>
      <dc:creator><![CDATA[rakhiguha]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rakhiguha/2015/10/06/sharepoint-user-profile-context-filter-webpart-using-powershell/</guid>
      <description><![CDATA[In sharepoint application very often we use listview webpart. Sometme on top of the current view we...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: small;">In sharepoint application very often we use listview webpart. Sometme on top of the current view we need to use filters for the list data.</span></p>
<p><span style="font-size: small;">In one of article I have explained how to implement the commonly used Query string webpart using powershell scripting.</span></p>
<p><span style="font-size: small;">In this article I will consolidate the details which deals with a User profile filter. It is almost same as of the other OOTB filter other than the highlighted parts.</span></p>
<p><span style="font-size: small;">Following piece of code is ready to use for the same purpose</span></p>
<pre><span style="font-size: small;"># SPWeb context </span><br /><span style="font-size: small;">$web = Get-SPWeb <em><strong>&lt;site url&gt;</strong></em></span></pre>
<pre><span style="font-size: small;">$PubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)&nbsp;<strong></strong><em><strong><br /></strong></em></span></pre>
<pre><span style="font-size: small;">#Get the webpart manager</span></pre>
<pre><span style="font-size: small;">$oWebPartManager = $web.GetLimitedWebPartManager(<em><strong>&lt;page url&gt;</strong></em>, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared);</span></pre>
<pre><span style="font-size: small;">#Get the list</span></pre>
<pre><span style="font-size: small;">$list = $web.Lists[<em><strong>&lt;List Name&gt;</strong></em>];</span></pre>
<pre><span style="font-size: small;">#Instantiate listview webpart and added to the page</span></pre>
<pre><span style="font-size: small;">$listVWP = New-Object Microsoft.SharePoint.WebPartPages.XsltListViewWebPart;</span><br /><span style="font-size: small;">$listVWP.Title =<em><strong>&lt;Listview webpart Title.</strong></em>;</span><br /><span style="font-size: small;">$listVWP.ChromeType = [System.Web.UI.WebControls.WebParts.PartChromeType]::None; </span><br /><span style="font-size: small;">$listVWP.Visible = $true;</span><br /><span style="font-size: small;">$listVWP.EnableViewState = $true;</span></pre>
<pre><span style="font-size: small;">$listVWP.ListName = <em><strong>&lt;List Name&gt;;</strong></em></span></pre>
<pre><span style="font-size: small;">$listVWP.ViewGuid = <em><strong>&lt;View Guid&gt;</strong></em></span><br /><span style="font-size: small;">$listVWP.WebId = $list.ParentWeb.ID;</span><br /><span style="font-size: small;">$listVWP.ListId = [System.Guid]$list.ID;</span></pre>
<p><span style="font-size: small;">&nbsp;$oWebPartManager.AddWebPart($listVWP, "Main", 0);</span></p>
<pre><span style="font-size: small;">$oWebPartManager.SaveChanges($listVWP);</span></pre>
<p><span style="font-size: small;">&nbsp; #Instantiate and add the Query webpart and set the connection</span></p>
<pre><span style="font-size: small;">$queryPart = <span style="background-color: #ffff00;">New-ObjectMicrosoft.SharePoint.Portal.WebControls.UserContextFilterWebPart;</span></span><br /><span style="font-size: small;">$queryPart.FilterName="<em><strong>&lt;Filter Name&gt;</strong></em>";</span></pre>
<pre><span style="font-size: small; background-color: #ffff00;">$queryPart.ProfilePropertyName="<em><strong>&lt;USER PROFILE PROPERTYC NAME&gt;</strong></em>";</span></pre>
<p><span style="font-size: small; background-color: #ffff00;">&nbsp; &nbsp;$queryPart.ValueKind="ProfileValue";</span></p>
<pre><br /><span style="font-size: small;">$queryPart.ChromeType = [System.Web.UI.WebControls.WebParts.PartChromeType]::None; </span><br /><span style="font-size: small;">$oWebPartManager.AddWebPart($queryPart, "Main", 0);</span><br /><span style="font-size: small;">$oWebPartManager.SaveChanges($queryPart);</span><br /><span style="font-size: small;">$provWPCPs = $oWebPartManager.GetProviderConnectionPoints($queryPart) ; </span><br /><span style="font-size: small;">$conWPCPs = $oWebPartManager.GetConsumerConnectionPoints($listVWP) ;</span><br /><span style="font-size: small;">foreach($provWPCP in $provWPCPs){</span><br />	<br /><span style="font-size: small;">if($provWPCP.ID -eq "ITransformableFilterValues"){</span><br /><span style="font-size: small;"> $providerCon = $provWPCP;</span><br /><span style="font-size: small;"> }</span><br /><span style="font-size: small;"> }</span><br /><br /><span style="font-size: small;"> foreach($conWPCP in $conWPCPs){</span><br /><br /><span style="font-size: small;"> if($conWPCP.ID -eq "DFWP Filter Consumer ID"){</span><br /><span style="font-size: small;"> $consumerCon = $conWPCP;</span><br /><span style="font-size: small;"> }</span><br /><span style="font-size: small;"> }</span><br /><span style="font-size: small;">$trans = New-Object Microsoft.SharePoint.WebPartPages.TransformableFilterValuesToParametersTransformer</span><br /><span style="font-size: small;">$trans.ConsumerFieldNames = new-object System.string("<em><strong>&lt;List Field on which Filter to be applied&gt;</strong></em>");</span><br /><span style="font-size: small;">$trans.ProviderFieldNames = new-object System.string("<strong>&lt;Filter Name&gt;</strong>");</span><br />	<br /><span style="font-size: small;">$newConn = $oWebPartManager.SPConnectWebParts($queryPart, $providerCon, $listVWP,$consumerCon, $trans)</span><br /><span style="font-size: small;">$oWebPartManager.SPWebPartConnections.Add($newConn);</span></pre>
<pre><span style="font-size: small;">$PublishingPage = $PubWeb.GetPublishingPage("<em><strong>&lt;Page Url&gt;</strong></em>");</span><br /><span style="font-size: small;">$PublishingPage.CheckIn("Auto deployed - intermediate");</span><br /><br /><span style="font-size: small;"># Fix for list web-part sorting/paging issue</span><br /><br /><span style="font-size: small;">$PublishingPage.CheckOut();</span><br />		<br /><span style="font-size: small;">$page = $web.GetFile("<em><strong>&lt;Page Url&gt;</strong></em>"); </span><br /><br /><span style="font-size: small;"> $wpmgr = $page.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared);</span><br />        <br /><span style="font-size: small;"> foreach($wpInstance in $wpmgr.WebParts)</span><br /><span style="font-size: small;"> {</span><br /><span style="font-size: small;"> if ($wpInstance.ToString() -eq "Microsoft.SharePoint.WebPartPages.XsltListViewWebPart")</span><br /><span style="font-size: small;"> {</span><br /><span style="font-size: small;"> $wpmgr.SaveChanges($wpInstance);</span><br /><span style="font-size: small;"> }</span><br /><span style="font-size: small;"> }</span><br /><br /><span style="font-size: small;">$page.Update();</span><br /><br /><span style="font-size: small;"># End fix for list web-part sorting/paging issue</span><br /><br /><span style="font-size: small;">$PublishingPage.CheckIn("Auto deployed - final");</span><br /><span style="font-size: small;">$PublishingPage.ListItem.File.Publish("Auto deployed - final");</span></pre>
<pre>&nbsp;</pre>
<pre><span style="font-size: small;">Now we are done with the scripting part once we run this script it will add the Listview,&nbsp;</span></pre>
<pre><span style="font-size: small;">Query string web part on the page and set the required connection.</span></pre>
<pre><span style="font-size: small;">In url if we pass the query string value the given list view will be filtered based on that.</span></pre>]]></content:encoded>
    </item>
    <item>
      <title>Resolution:List View webpart sorting not working when added through powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/rakhiguha/resolutionlist-view-webpart-sorting-not-working-when-added-through-powershell</link>
      <pubDate>Mon, 05 Oct 2015 04:25:00 GMT</pubDate>
      <dc:creator><![CDATA[rakhiguha]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rakhiguha/2015/10/05/resolutionlist-view-webpart-sorting-not-working-when-added-through-powershell/</guid>
      <description><![CDATA[Recently we faced a strange issue in one of our project. We added few list view webparts on...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: small;">Recently we faced a strange issue in one of our project. We added few list view webparts on different pages using powershell scripting as part of the deployment infrastructure.</span></p>
<p><span style="font-size: small;">It was the usual scripting used everywhere. The listview webparts were added properly to the page with the following script</span></p>
<p>&nbsp;</p>
<pre><span style="font-size: small;">$web = Get-SPWeb <em><strong>&lt;site url&gt;</strong></em></span></pre>
<pre><span style="font-size: small;">$PubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)&nbsp;<strong></strong><em><strong><br /></strong></em></span></pre>
<pre><span style="font-size: small;">#Get the webpart manager</span></pre>
<pre><span style="font-size: small;">$oWebPartManager = $web.GetLimitedWebPartManager(<em><strong>&lt;page url&gt;</strong></em>, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared);</span></pre>
<pre><span style="font-size: small;">#Get the list</span></pre>
<pre><span style="font-size: small;">$list = $web.Lists[<em><strong>&lt;List Name&gt;</strong></em>];</span></pre>
<pre><span style="font-size: small;">#Instantiate listview webpart and added to the page</span></pre>
<pre><span style="font-size: small;">$listVWP = New-Object Microsoft.SharePoint.WebPartPages.XsltListViewWebPart;</span><br /><span style="font-size: small;">$listVWP.Title =<em><strong>&lt;Listview webpart Title.</strong></em>;</span><br /><span style="font-size: small;">$listVWP.ChromeType = [System.Web.UI.WebControls.WebParts.PartChromeType]::None; </span><br /><span style="font-size: small;">$listVWP.Visible = $true;</span><br /><span style="font-size: small;">$listVWP.EnableViewState = $true;</span></pre>
<pre><span style="font-size: small;">$listVWP.ListName = <em><strong>&lt;List Name&gt;;</strong></em></span></pre>
<pre><span style="font-size: small;">$listVWP.ViewGuid = <em><strong>&lt;View Guid&gt;</strong></em></span><br /><span style="font-size: small;">$listVWP.WebId = $list.ParentWeb.ID;</span><br /><span style="font-size: small;">$listVWP.ListId = [System.Guid]$list.ID;</span></pre>
<p><span style="font-size: small;">&nbsp;$oWebPartManager.AddWebPart($listVWP, "Main", 0);</span></p>
<p>&nbsp;</p>
<p><span style="font-size: small;">Once added to the page we realized that the sorting and filtering option from the Out of the box sharepoint feature for these webparts not functioning. We tried few things during investigation to resolve the issue. We tried to add the same listview from UI and then introspect both the webparts from sharepoint designer.</span></p>
<p><span style="font-size: small;">But we&nbsp;couldn't&nbsp;figure out any fruitful solution. Then just realized the Savechanges method invocation is missing from our code hence added the below piece of code</span></p>
<pre><span style="font-size: small;">$oWebPartManager.SaveChanges($listVWP);</span></pre>
<pre><span style="font-size: small;">This time once the deployment done to our surprise all seems to be working and ends with a happy note.</span></pre>
<pre><span style="font-size: small;">Still figuring out what extra this single line of code leads to the magic :)</span></pre>
<p><span><br /></span></p>]]></content:encoded>
    </item>
    <item>
      <title>Sharepoint Query String Filter webpart using powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/rakhiguha/sharepoint-query-string-filter-webpart-using-powershell</link>
      <pubDate>Sun, 04 Oct 2015 21:37:00 GMT</pubDate>
      <dc:creator><![CDATA[rakhiguha]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rakhiguha/2015/10/04/sharepoint-query-string-filter-webpart-using-powershell/</guid>
      <description><![CDATA[Despite of some limitations often we need to deal with filter webparts in sharepoint application....]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: small;">Despite of some limitations often we need to deal with filter webparts in sharepoint application. Query string filter is is very common and widely used. And sometime it is required to automate the entire process, in order to do so powershell scripting is must.</span></p>
<p><span style="font-size: small;">Here I will just explain using powershell scripting how to add</span></p>
<p><span style="font-size: small;">1. A Listview webpart with a Query string filter webpart on a sharepoint page</span></p>
<p><span style="font-size: small;">2. Establish the connection between the two webpart</span></p>
<pre><span style="font-size: small;"># SPWeb context </span><br /><span style="font-size: small;">$web = Get-SPWeb <em><strong>&lt;site url&gt;</strong></em></span></pre>
<pre><span style="font-size: small;">$PubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)&nbsp;<strong></strong><em><strong><br /></strong></em></span></pre>
<pre><span style="font-size: small;">#Get the webpart manager</span></pre>
<pre><span style="font-size: small;">$oWebPartManager = $web.GetLimitedWebPartManager(<em><strong>&lt;page url&gt;</strong></em>, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared);</span></pre>
<pre><span style="font-size: small;">#Get the list</span></pre>
<pre><span style="font-size: small;">$list = $web.Lists[<em><strong>&lt;List Name&gt;</strong></em>];</span></pre>
<pre><span style="font-size: small;">#Instantiate listview webpart and added to the page</span></pre>
<pre><span style="font-size: small;">$listVWP = New-Object Microsoft.SharePoint.WebPartPages.XsltListViewWebPart;</span><br /><span style="font-size: small;">$listVWP.Title =<em><strong>&lt;Listview webpart Title.</strong></em>;</span><br /><span style="font-size: small;">$listVWP.ChromeType = [System.Web.UI.WebControls.WebParts.PartChromeType]::None; </span><br /><span style="font-size: small;">$listVWP.Visible = $true;</span><br /><span style="font-size: small;">$listVWP.EnableViewState = $true;</span></pre>
<pre><span style="font-size: small;">$listVWP.ListName = <em><strong>&lt;List Name&gt;;</strong></em></span></pre>
<pre><span style="font-size: small;">$listVWP.ViewGuid = <em><strong>&lt;View Guid&gt;</strong></em></span><br /><span style="font-size: small;">$listVWP.WebId = $list.ParentWeb.ID;</span><br /><span style="font-size: small;">$listVWP.ListId = [System.Guid]$list.ID;</span></pre>
<p><span style="font-size: small;">&nbsp;$oWebPartManager.AddWebPart($listVWP, "Main", 0);</span></p>
<pre><span style="font-size: small;">$oWebPartManager.SaveChanges($listVWP);</span></pre>
<p><span style="font-size: small;">#Instantiate and add the Query webpart and set the connection</span></p>
<pre><span style="font-size: small;">$queryPart = New-Object Microsoft.SharePoint.Portal.WebControls.QueryStringFilterWebPart;</span><br /><span style="font-size: small;">$queryPart.FilterName="<em><strong>&lt;Filter Name&gt;</strong></em>";</span><br /><span style="font-size: small;">$queryPart.QueryStringParameterName = "<em><strong>&lt;query string parameter name&gt;</strong></em>"; </span><br /><span style="font-size: small;">$queryPart.ChromeType = [System.Web.UI.WebControls.WebParts.PartChromeType]::None; </span><br /><span style="font-size: small;">$oWebPartManager.AddWebPart($queryPart, "Main", 0);</span><br /><span style="font-size: small;">$oWebPartManager.SaveChanges($queryPart);</span><br /><span style="font-size: small;">$provWPCPs = $oWebPartManager.GetProviderConnectionPoints($queryPart) ; </span><br /><span style="font-size: small;">$conWPCPs = $oWebPartManager.GetConsumerConnectionPoints($listVWP) ;</span><br /><span style="font-size: small;">foreach($provWPCP in $provWPCPs){</span><br />	<br /><span style="font-size: small;">if($provWPCP.ID -eq "ITransformableFilterValues"){</span><br /><span style="font-size: small;"> $providerCon = $provWPCP;</span><br /><span style="font-size: small;"> }</span><br /><span style="font-size: small;"> }</span><br /><br /><span style="font-size: small;"> foreach($conWPCP in $conWPCPs){</span><br /><br /><span style="font-size: small;"> if($conWPCP.ID -eq "DFWP Filter Consumer ID"){</span><br /><span style="font-size: small;"> $consumerCon = $conWPCP;</span><br /><span style="font-size: small;"> }</span><br /><span style="font-size: small;"> }</span><br /><span style="font-size: small;">$trans = New-Object Microsoft.SharePoint.WebPartPages.TransformableFilterValuesToParametersTransformer</span><br /><span style="font-size: small;">$trans.ConsumerFieldNames = new-object System.string("<em><strong>&lt;List Field on which Filter to be applied&gt;</strong></em>");</span><br /><span style="font-size: small;">$trans.ProviderFieldNames = new-object System.string("<strong>&lt;Filter Name&gt;</strong>");</span><br />	<br /><span style="font-size: small;">$newConn = $oWebPartManager.SPConnectWebParts($queryPart, $providerCon, $listVWP,$consumerCon, $trans)</span><br /><span style="font-size: small;">$oWebPartManager.SPWebPartConnections.Add($newConn);</span></pre>
<pre><span style="font-size: small;">$PublishingPage = $PubWeb.GetPublishingPage("<em><strong>&lt;Page Url&gt;</strong></em>");</span><br /><span style="font-size: small;">$PublishingPage.CheckIn("Auto deployed - intermediate");</span><br /><br /><span style="font-size: small;"># Fix for list web-part sorting/paging issue</span><br /><br /><span style="font-size: small;">$PublishingPage.CheckOut();</span><br />		<br /><span style="font-size: small;">$page = $web.GetFile("<em><strong>&lt;Page Url&gt;</strong></em>"); </span><br /><br /><span style="font-size: small;"> $wpmgr = $page.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared);</span><br />        <br /><span style="font-size: small;"> foreach($wpInstance in $wpmgr.WebParts)</span><br /><span style="font-size: small;"> {</span><br /><span style="font-size: small;"> if ($wpInstance.ToString() -eq "Microsoft.SharePoint.WebPartPages.XsltListViewWebPart")</span><br /><span style="font-size: small;"> {</span><br /><span style="font-size: small;"> $wpmgr.SaveChanges($wpInstance);</span><br /><span style="font-size: small;"> }</span><br /><span style="font-size: small;"> }</span><br /><br /><span style="font-size: small;">$page.Update();</span><br /><br /><span style="font-size: small;"># End fix for list web-part sorting/paging issue</span><br /><br /><span style="font-size: small;">$PublishingPage.CheckIn("Auto deployed - final");</span><br /><span style="font-size: small;">$PublishingPage.ListItem.File.Publish("Auto deployed - final");</span></pre>
<pre>&nbsp;</pre>
<pre><span style="font-size: small;">Now we are done with the scripting part once we run this script it will add the Listview,&nbsp;</span></pre>
<pre><span style="font-size: small;">Query string web part on the page and set the required connection.</span></pre>
<pre><span style="font-size: small;">In url if we pass the query string value the given list view will be filtered based on that.</span></pre>
<pre>&nbsp;</pre>]]></content:encoded>
    </item>
    <item>
      <title>Active Directory: How to update User thumbnail photo using Service Account</title>
      <link>https://docs.microsoft.com/archive/blogs/rakhiguha/active-directory-how-to-update-user-thumbnail-photo-using-service-account</link>
      <pubDate>Sun, 27 Sep 2015 22:17:00 GMT</pubDate>
      <dc:creator><![CDATA[rakhiguha]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rakhiguha/2015/09/27/active-directory-how-to-update-user-thumbnail-photo-using-service-account/</guid>
      <description><![CDATA[Update active directory properties from an application is not a frequent scenario. Generally it is...]]></description>
      <content:encoded><![CDATA[<p>Update active directory properties from an application is not a frequent scenario. Generally it is handled by domain administrator, but in one of my current project it was required to update the user photo from a sharepoint application and client did not want to use the user profile sync service. In addition the entire process was based on some project specific pre condition.</p>
<p>As a result it was required some piece of c# coding to enable the Active directory data update. There are several articles on how to update an attribute in active directory, still for reference one can use the below code snippets&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p>//Open file</p>
<p>System.IO.FileStream inFile = new System.IO.FileStream(strFileName,System.IO.FileMode.Open,System.IO.FileAccess.Read);&nbsp;</p>
<p>//Retrieve Data into a byte array variable</p>
<p>byte[] binaryData = new byte[inFile.Length];&nbsp;</p>
<p>int bytesRead = inFile.Read(binaryData, 0, (int)inFile.Length);</p>
<p>inFile.Close();</p>
<p>//Connect to AD</p>
<p>System.DirectoryServices.DirectoryEntry myUser = new System.DirectoryServices.DirectoryEntry("LDAP://" + &lt;DISTINGUISHEDNAME FROM AD&gt;);</p>
<p>--&lt;DISTINGUISHEDNAME FROM AD Something Like CN=UserName,OU=User,DC=SampleDomain,DC=local</p>
<p>&nbsp;// Clear existing picture if exists</p>
<p>myUser.Properties["thumbnailPhoto"].Clear();&nbsp;</p>
<p>//Update attribute with binary data from file</p>
<p>myUser.Properties["thumbnailPhoto"].Add(binaryData);</p>
<p>myUser.CommitChanges();</p>
<p>&nbsp;</p>
<p>Now the challenge was this should be executed under a service account as for all user we are supposed to open then access door to update the Active directory properties.</p>
<p>To accomplish this there are certain changes we need to apply at Active directory end and trust me it was a real pain to find out &nbsp;how to enable the permission for a specific user. There are several articles/blog which states the delegation but there are some additional steps that has to be executed on Active directory.</p>
<p>Here are the below required steps</p>
<p><strong><span style="text-decoration: underline;">Steps to enable Thumbnail photo update using Service Account</span></strong></p>
<p><strong></strong><strong>1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </strong><strong>Assign Recipient provisioning permission</strong></p>
<ul>
<li>Login to the Exchange server with Active directory admin account.</li>
<li>Run the powershell cmdlet.</li>
<li>Execute the following command</li>
</ul>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="779">
<p>Get-RoleGroup "Organization Management" | Add-RoleGroupMember -Member <strong><em>&lt;SERVICE ACCOUNT&gt;</em></strong></p>
</td>
</tr>
<tr>
<td valign="top" width="779">
<p>Get-RoleGroup "Recipient Management" | Add-RoleGroupMember -Member <strong><em>&lt;SERVICE ACCOUNT&gt;</em></strong></p>
</td>
</tr>
<tr>
<td valign="top" width="779">
<p>Get-RoleGroup "Help Desk" | Add-RoleGroupMember -Member <strong><em>&lt;SERVICE ACCOUNT&gt;</em></strong>&nbsp;</p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;<strong>2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </strong><strong>Provide Delegate control to service account with thumbnail photo attribute read/write permission</strong></p>
<ul>
<li>Load "Active Directory Users and Computers" Management Console (dsa.msc).</li>
<li>Right click on the Domain or Organizational Unit containing the Domain Users that you would like your assigned user to be able to upload pictures for and select "Delegate Control". The "Delegation of Control Wizard" will be displayed on the screen. Click Next.</li>
</ul>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/2678.Untitled.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/2678.Untitled.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/2678.Untitled.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/2678.Untitled.png" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<ul>
<li>Click the "Add" button to add the user(s) or group who you would like to grant permissions to change the Outlook Photo to and Click Next.&nbsp;</li>
</ul>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/4380.Untitled.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/4380.Untitled.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/4380.Untitled.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/4380.Untitled.png" alt="" border="0" /></a></p>
<ul>
<li>On the "Task to Delegate" page click the radio button "Create a custom task to delegate". Click Next.&nbsp;</li>
</ul>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/8662.Untitled.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/8662.Untitled.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/8662.Untitled.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/8662.Untitled.png" alt="" border="0" /></a></p>
<ul>
<li>On the "Active Directory Object Type" page choose the radio button "Only the following objects in the folder" and tick the check box "User objects". Click Next.</li>
</ul>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/5355.Untitled.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/5355.Untitled.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/5355.Untitled.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/5355.Untitled.png" alt="" border="0" /></a>&nbsp;</p>
<ul>
<li>On the "Permissions" page tick the check box "Property-specific" then in the permissions list tick the boxes for "Read thumbnail Photo" and "Write thumbnailPhoto". Click Next:</li>
</ul>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/6013.Untitled.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/6013.Untitled.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/65/92/6013.Untitled.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-65-92/6013.Untitled.png" alt="" border="0" /></a></p>
<ul>
<li>Click "Finish" to complete the "Delegation of Control Wizard"</li>
</ul>
<p>&nbsp;</p>]]></content:encoded>
    </item>
  </channel>
</rss>