Tuesday, August 20, 2013

SharePoint 2013 migration issue with the SP.UI.ModalDialog error in javascript of CEWP

When there are javascript added to the Content Editor Web Part in SharePoint 2010, to open the dialog the code below is how you would do it but it breaks when you upgrade to 2013.

This works best if you add the new Script Webpart to the page and copy and paste all the scripts from the CEWP and leave the html as is.  

function openFormDialog(formtitle, formurl)
{
 var options = {
             url: formurl,
             tite: formtitle
         };

         SP.UI.ModalDialog.showModalDialog(options);
}

breaks in 2013

to fix the issue change the call to

function openFormDialog(formtitle, formurl)
{
 var options = {
             url: formurl + "?IsDlg=1",
             tite: formtitle
         };

SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}

SharePoint 2013 migration issue with javascript only content editor webpart breaking the webpart page and closes the browser

Here is a simple script to output the contents of the CEWP to be ran on the 2010 environment to investigate the potential issues you might encounter for javascript only CEWP when it gets migrated to 2013.


$siteUrl = "http://localhost"
$site = Get-SPSite $siteUrl
$cewpCount = 0
$cewps = New-Object Hashtable
$site.AllWebs | % {

     $pageUrl = $_.RootFolder.WelcomePage;
     $pageUrlFull = ($_.Url + "/" + $pageUrl);
     if($pageUrl.Length -gt 0 )
     {
       $parts = $_.GetWebPartCollection($pageUrl, 2)
         $parts | ? { $_.WebBrowsableObject.ToString() -eq "Microsoft.SharePoint.WebPartPages.ContentEditorWebPart" } | % {
         $ce = [Microsoft.SharePoint.WebPartPages.ContentEditorWebPart]$_
         Write-Host "Found on Page URL: " $pageUrlFull $_.StorageKey $ce.Title -ForegroundColor Green
          Write-Host $ce.Content.InnerText
          $cewpCount += 1;
          $cewps.Add($_.StorageKey, $pageUrlFull); }
      }    
    }
          
Write-Host "Found" $cewpCount "CEWPs" -ForegroundColor Green




Friday, August 16, 2013

SharePoint CAML query to get Todays events in calendar list

<Query>
    <OrderBy>
<FieldRef Name="EventDate"/>
</OrderBy>
<Where>
<And>
<DateRangesOverlap>
<FieldRef Name="EventDate"/>
<FieldRef Name="EndDate"/>
<FieldRef Name="RecurrenceID"/>
<Value Type="DateTime" IncludeTimeValue="False">
       <Today/>
                </Value>
            </DateRangesOverlap>
            <Lt>
                <FieldRef Name="EventDate"/>
                <Value Type="DateTime">
                   <Today/>
                </Value>
            </Lt>
        </And>
    </Where>
    <QueryOptions>
        <IncludeMandatoryColumns>false</IncludeMandatoryColumns>
        <ViewAttributes Scope="Recursive"/>
        <RecurrencePatternXMLVersion>v3</RecurrencePatternXMLVersion>
        <ExpandRecurrence>true</ExpandRecurrence>
        <RecurrenceOrderBy>true</RecurrenceOrderBy>
        <ViewAttributes Scope="RecursiveAll"/>
        <CalendarDate>
        <Today/>
        </CalendarDate>
    </QueryOptions>
</Query>

Wednesday, August 14, 2013

PowerShell Script to mount and Upgrade all site collections in a web application

Sometimes, the visual upgrade gets a bit buggy so use this instead and have no issues. Make sure you export all the solutions from the old central admin and add them and deploy them to the new Sharepoint 2013 environment. This way you will not have issues with the webparts and pages.

Add-PSSnapin Microsoft.SharePoint.Powershell
Mount-SPContentDatabase CSIHQ_Content -WebApplication http://server.com -AssignNewDatabaseId -DatabaseServer Dbservername
$SPwebApp = Get-SPWebApplication "http://server.com"
foreach ($SPsite in $SPwebApp.Sites) { Upgrade-SPSite $SPsite.Url -VersionUPGrade write-host $SPsite.url }

Friday, August 9, 2013

TFS 2012 and Visual studio 2010 CodedUI Project error: The given key was not present in the dictionary

Encountered a strange error today.  When i open a UIMap from an old project the error says "The given key was not present in the dictionary".   After doing some research, everyone suggested removing the files in the local directory but that did not work for me.

So i removed and AssemblyInfo.cs and then undid checkout/pending changes.

The IDE gives an file modification detected warning and askes to reload.
Click Reload.

The UIMap opens without an issue.