Monday, April 20, 2015

Sharepoint Task List - hiding the timeline from a view in c#

Ever wonder how to remove the timeline from a task list view using c#?  Me too.  Here is the answer...


var list = web.Lists[Constants.Lists.TaskList];
var view = list.Views["All Tasks"];
view.ViewData = "";
view.Update();  

That's hours and hours of my life I'll never get back.

Wednesday, March 4, 2015

SharePoint 2013 - edit navigation term with powershell

I had a requirement to edit a term for a site with powershell to set the "Change target page for this term" property for a term-driven page.

The powershell I used is:

$site = Get-SPSite $portalUrl
$taxSession = Get-SPTaxonomySession -Site $site
$termStore = $taxSession.TermStores[$managedMetadataService]
$termStoreGroup = $termStore.Groups[$termStoreGroup]
$termSet = $termStoreGroup.TermSets[$termSet]
$term = $termSet.Terms.Item($term)
$term.SetLocalCustomProperty("_Sys_Nav_TargetUrl", $newUrl)
$termStore.CommitAll()

Sunday, February 22, 2015

Sharepoint 2013 - showing Task Due Date in Content Query Web Part (CQWP)

To get the Due Date of a task to appear in a content query web part you need to configure the web part to use 'TaskDueDate', not 'DueDate'.  This then resolves in the web part to Due Date [Core Task and Issue Columns].

Visual Studio stuck on "Waiting for parse to complete..."

Today when I opened my sharepoint 2013 solution in Visual Studio 2013 it got stuck loading a project with the message in the status bar of "Waiting for parse to complete...".  Yesterday before I closed visual studio I was looking at a large xsl file which I had left open before closing visual studio.  I think this may have been the file it was stuck on?

The way I fixed it was to remove the mapping in Visual Studio to the solution and re-add it in Source Control Explorer.  To remove mapping:
  1. Backup your source code to another folder
  2. go to Source Control Explorer
  3. right click on the folder that contains the solution
  4. Go to Advanced > Remove Mapping...

Monday, February 16, 2015

Visual Studio - display selected file in solution explorer

Everytime I need to set this up I can't remember how. 

It is very handy when you have a Visual Studio project with a large number of files to have the file you are working on highlighted in the solution explorer.  This doesn't happen automatically but is super easy to set up.

Tools > Options > Projects and Solutions > General > Track Active item in Solution Explorer

Done!

Monday, February 9, 2015

User Profile Synchronization Service

That old gem of getting the user profile synchronization service running bit me today.  Thanks so much to SharePointBjorn for supplying the powershell script to fix it.

Sunday, February 8, 2015

SharePoint 2013 - Creating a view to show tasks assigned to me and groups that I am a member of

I have a requirement to create a view to show tasks that are:
  • assigned to me, and
  • assigned to groups that I am a member of
Thanks to this blog for the answer:  Filter Sharepoint Task Llist View To Show Tasks Assigned To Groups I am in.

The Where clause for the view needs to be:

 
<Or>
  <Membership Type="CurrentUserGroups">
    <FieldRef Name="AssignedTo"/>
  </Membership>
  <Eq>
    <FieldRef Name="AssignedTo"/>
    <Value Type="Integer">
      <UserID/>
    </Value>
  </Eq>
</Or>


And that is all.

Wednesday, February 4, 2015

SharePoint 2013 - Adding a ListViewWebPart throws error "The specified view is invalid"

Today I encounted an issue where I was programatically adding a ListViewWebPart to a page and getting an exception "The specified view is invalid".

The code throwing the exception was

            var listViewWebPart = new ListViewWebPart 
            {
                ListId = list.ID, 
                ChromeType = PartChromeType.None,
                ViewGuid = list.Views[Constants.ViewNames.DocumentLibraryAllDocumentSets].ID.ToString("B").ToUpper()
            };
            webPartManager.AddWebPart(listViewWebPart, "Top", 1);

The solution was to change ListViewWebPart to XsltListViewWebPart. Once I did that the problem went away.

Tuesday, February 3, 2015

Sharepoint 2013 - create mapped properties with powershell

It has been many years and a couple of versions of SharePoint since I posted and I figured it's time to resurrect SharePoint Wisdom.  What better way to start than a sample powershell function that will add/edit a managed property and map a crawled property to it in SharePoint 2013.

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

Function UpdateManagedPropertyMapping([string]$managedPropertyName, [string]$crawledPropertyName, $searchApp)
{
    $managedProperty = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchApp -Identity $managedPropertyName -ErrorAction SilentlyContinue
    Write-Host Adding/Updating managed property $managedPropertyName

    if($managedProperty -eq $null)
    {
        #create a new property
        Write-Host Creating managed property $managedPropertyName
        $managedProperty = New-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchApp -Name $managedPropertyName -Type 1 -Queryable $true -Retrievable $true 
        $managedProperty.Refinable = $true
        $managedProperty.Sortable = $true
        $managedProperty.Update()
        Write-Host Created managed property $managedPropertyName
    }
    else
    {
        Write-Host Managed property $managedPropertyName already exists
    }

    $managedPropertyMapping = Get-SPEnterpriseSearchMetadataMapping -SearchApplication $searchApp -ManagedProperty $managedProperty
    if($managedPropertyMapping)
    {
        #remove mapping
        Write-Host Removing existing mapping
        Remove-SPEnterpriseSearchMetadataMapping -Identity $managedPropertyMapping -Confirm:$false

    }
    Write-Host Mapping property $crawledPropertyName to $managedPropertyName
    $crawledProperty = Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchApp -Name $crawledPropertyName
    $managedPropertyMapping = New-SPEnterpriseSearchMetadataMapping -SearchApplication $searchApp -ManagedProperty $managedProperty -CrawledProperty $crawledProperty

    Write-Host Finished adding/updating managed property $managedPropertyName
}

$searchApp = Get-SPEnterpriseSearchServiceApplication
UpdateManagedPropertyMapping FFBoKAuthor ows_Author0 $searchApp
UpdateManagedPropertyMapping FFBoKPublicationYear ows_CategoryLevel1 $searchApp
UpdateManagedPropertyMapping FFBoKCategory1 ows_CategoryLevel1 $searchApp

I hope this script proves useful to someone.

Tuesday, April 21, 2009

Visual Studio 2008 Office 2007 templates missing

I just tried to create a new SharePoint 2007 Sequential Workflow in Visual Studio 2008, but when I navigated to Office 2007 in the project types no templates appeared.

I scratched my head for about 10 minutes and then noticed that I had selected .NET Framework 3.0 as the .NET version. Changing this to .NET Framework 3.5 fixed the problem.






Tuesday, February 10, 2009

Retrieving the COM class factory for component with CLSID {3D42CCB1-4665-4620-92A3-478F47389230} failed due to the following error: 80070005

I came across this error in SharePoint yesterday. It seemed to spontaneously occur for no reason I could figure out and seemed to be linked to importing user profiles from Active Directory. The import stopped working and this error started to appear.

After searching I found a few articles suggesting to fix permissions on the OSearch component. One of these is http://www.sharepointblogs.com/jasonmedero/archive/2008/02/08/after-applying-moss-2007-sp1-event-log-error-retrieving-the-com-class-factory-for-component-with-clsid-3d42ccb1-4665-4620-92a3-478f47389230-failed-due-to-the-following-error-80070005.aspx

I checked these permissions and found that they were already correct. What I did try then was to stop and start the osearch service.

Restarting the osearch service made the error go away BUT then when I tried to go to the User Profile page in the SSP I got a new error which stated there was a problem connecting to the database or to the search. Upon further investigation I discovered that the SSP web application had lost it's connection to the indexer. Once I added this back in it seemed to work fine again.

Tuesday, July 8, 2008

Wildcard Search in MOSS

Earlier this year I was asked to implement wildcard people search in MOSS. The solution I went with wasn't pretty and I wish I could go back and do it again. If I could do it again I would try to use the method outlined in this article with some customisations to make it work for People Search: Web Part for Wildcard Search in Enterprise Search

The way I had originally gone about it was to create a custom people search box based on this article. It worked really well EXCEPT that if any of my criteria were null for the person but they met other search criteria they would not show up in the results.

Tuesday, June 17, 2008

.NET and SharePoint Interview questions

My list of .NET and SharePoint interview questions

.NET Questions

Describe what an Interface is and how it differs from a class.



What is polymorphism?



What is reflection



How is the using() pattern useful? What is IDisposable?




What is an abstract class?




Can you name some major ASP.net objects: Session, Page, Server, Response, Request, Application




Can you describe the ASP.NET page lifecycle? What methods are fired during the page load? Page request, Start, Page Initialisation, Load, Validation, Postback event handling, Rendering, Unload. PreInit, Init, InitComplete, PreLoad, OnLoad, control events, LoadComplete, PreRender, SaveStateComplete, the page calls Render for each control, Unload




How do you store information across postbacks? What different ways are there? Which one do you prefer and why? ViewState, Query Strings, Application, Session




What is an n-tier design? Can you give an example?
What is AJAX? Have you used it? Examples?




Can you used application blocks in your programming? Which ones?




Patterns?



SharePoint Questions

What are content types and how are they used? Can you give me an example of where you have used them?




What elements does SharePoint provide to allow you to define the look and feel of a publishing site? Master Page, Page Layouts, Content types, CSS




How could you display information from a list on one site on another site in the same site collection? Dataview, CQWP, RSS.




Why would you want to extend a web application?




What is the 12 hive OR can you tell me where SharePoint stores it’s files




Are you familiar with the file onet.xml? What is it? Site Definition file




What is a Feature




What is a Solution




What is SPWeb, SPSite. Can you tell me anything special that a developer must keep in mind when using these objects in code?




What is SharePoint Designer? How have you used it?

Sunday, May 25, 2008

Closed web part gallery

Are you trying to find the closed web part gallery? I was, then I found it here:

1. Click on Edit Page
2. Click on Add Web Part
3. When you get the list of web parts that are available, click on Advanced.
4. Now you will see any web parts that were closed

Wednesday, May 14, 2008

Branding meeting workspaces

I recently had an issue where I created a master page and tried to apply it (using feature stapling) to sites based on meeting workspace site templates. The lessons learnt from this were:

  1. Meeting workspaces don't use default.master. They use MWSdefault.master. Base the master page for meeting workspaces on MWSdefault.master as it has extra functionality specific to meeting workspaces.
  2. When setting the master page programatically, you need to set two properties as follows:
    web.MasterUrl = "something.master";
    web.CustomMasterUrl = "something.master";
    For sites based on other site templates I only had to set web.MasterUrl.

Monday, May 12, 2008

Wednesday, May 7, 2008

Dispose of SPWeb and SPSite objects

When coding in SharePoint you should ALWAYS dispose of SPWeb and SPSite objects. They use a small amount of managed code and a large amount of unmanaged code. As a result of the small managed code, the garbage collector doesn't clear out the items from memory which can lead to a world of pain...

Best Practices: Using Disposable Windows SharePoint Services Objects

SharePoint Data Protection and recovery

White paper: Data protection and recovery for Office SharePoint Server in small to medium deployments