News feed with CQWP

How come I always tell the company I work or consult for, that I am not a developer.. and then I always end up developing stuff anyway? For my part, it is more of a frustration part, because it takes so much time to develop than to use the out of the box functionality. But sometimes out of the box is just not enough.

The last few months I have been working on setting up a SP 2010 server farm from scratch, setting up a new intranet, branded it, structuring it and… developing some parts like the News rollup. I have used the CQWP and it is so powerful, I love it. I have built kind of a Facebook news stream with it, that rolls up news from all departments, the site image and source where the news comes from and also ratings and news images.

This is the result:

And here is an explanation of the parts on the news webpart:

This is how I built the CQWP:

I have built a custom news page layout, where I have a site column called “Siteimage” where I store the actual site image. (The site image is marked with a red number 1 in the image above). So there will be different site images depending on where the news are created. In this case I have for example a picture of a vessel if the news comes from a vessel site. And that is how Facebook news feed works, you have the source image to the left in the news feed (the profile picture) and if you click on the news you will land on that persons wall. This works the same way, but you will land on the site where the news was created.

Red number 2 in the picture above shows that I have selected the Title and Byline and the title is the URL to the news page.

Then I have added the site title (our sites are named by department), the Author and the Article Date as red number 3 shows in the picture above.

Of course any thumbnail photos are displayed and you can make them clickable so they enlarge on click (red number 4 in picture above)

And last, I wanted to add the ratings since I like the social interaction also. Red number 5 in pic above, if not obvious 🙂 In fact, I also have added the Note board to our news, so if you open the news page you can post comments on it. I have not added the “Comments” though on the front page, since I have not found any good way to do that. I don’t think the Note board comments are connected to the page itself, but maybe someone out there knows? I have found a way to display comments on Blogs, but not on Page libraries.

My next news project will be based completely on Blogs. There are many reasons for that: it is so easy to blog (and use Word if the user wants to), the entire news is displayed, you can display ratings and number of comments, I have built the similiar news feed as above but using Blog instead.

I really like the CQWP but I wish it was even more flexible and that you could perform lookups on custom fields and values a bit easier. And maybe a drag and drop GUI to build the CQWP without having to export and import it, copy and modify xsl etc. Also, you need to be very creative and use your imagination to find the solution on how to bring out the stuff you want to show in your CQWP.

Share this blog post:

Setup connection filter on AD

If you want to reduce the amount of user profiles that are imported from AD, then a good way is to filter the AD connection. Then you can filter out disabled accounts and for example, accounts that does not have a mail address. Go to you AD connection in the User Profile Service Application and hover the name of the AD connection. Click on “Edit connection filters”:

To filter out disabled accounts, select “userAccountControl” from the Attributes list, and wait for the page to reload.

Then select “Bit on equals” and set it to “2” (without quotation marks)


To filter out accounts that does not have a mail address, select “mail” from the Attributes list and wait for the page to reload.
Then select “not present” from the Operator list.

Share this blog post:

Cmdlets I use most often

I love the power of PowerShell. And I use it a lot to do stuff, it is much easier and faster than using CA. And I find myself googling Microsoft or other pages over and over for the same commands, because I simply cannot remember the parameters and it is faster to just google it. So I will add them here now, for my own convenience! Copy and paste away 😉


Install-SPFeature -path “MySiteLayouts”
Enable-SPFeature -Identity MySiteLayouts -Url https://sps
Uninstall-SPFeature “MySiteLayouts”
Disable-SPFeature “MySiteLayouts” -Url https://sps


Add-SPSolution E:SP_install_filesWebpartsWebPart.wsp
Install-SPSolution –Identity WebPart.wsp –WebApplication https://sps -GACDeployment

Delete a list by GUID

$w = Get-SPWeb “https://sps

Create a site using custom template

Get custom template ID
$url = “https://sps
$site= new-Object Microsoft.SharePoint.SPSite($url )
$loc= [System.Int32]::Parse(1033)
$templates= $site.GetWebTemplates($loc)
foreach ($child in $templates){ write-host $child.Name ”  ” $child.Title }

Create a new site with the custom template id
$newWeb = New-SPWeb -Url https://sps/newsite -Name “New Site Name”

Delete database

$del = get-spdatabase “9437afae-953a-4373-81dc-88186e0ec30e”

Get all site features and save them in a txt file

Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope DisplayName,Id > E:outputAllInstalledFeatures.txt

Create new site and import cmp

New-SPWeb -url “https://sps/docs/
Import-SpWeb -identity “https://sps/documents/” -path “E:importsdocs.cmp” -IncludeUserSecurity

Import photo thumbnails from AD

Note: To be able to import the photos you need to first add an import of those in the User Profile Service Application. Go to User Properties, scroll down to “Pictures”, scroll down to the list of AD fields and select “thumbnailphoto”. Click on Import and add it. Save and do a full user profile import synchronization. Then you can run this command (I have this in Scheduled Tasks, it runs every night):

Update-SPProfilePhotoStore -CreateThumbnailsForImportedPhotos 1 -MySiteHostLocation https://mysites

Create State Service Application

New-SPStateServiceDatabase –Name “StateService” | New-SPStateServiceApplication –Name “State Service” | New-SPStateServiceApplicationProxy –DefaultProxyGroup

Start a Service Application

Often the WSS_Usage service application is not started by default when you install a new server.

$UP = Get-SPServiceApplicationProxy | where {$_.ID -eq “e31e3a1b-3c46-42d0-ad78-822cb48daafc”}

The GUID is the service application that is not started.

Share this blog post:

Why managed metadata sucks

Why is it that you often start doing things in SharePoint that you find really useful, and when you have almost reached your goal – the whole idea just falls? This happened to me when I setup a taxonomy for a department, we built the trees and deployed them to the libraries. All looked really good and we should start adding files. And when you setup a new intranet, you usually have a lot of files you want to upload at the same time to the libraries. No worries, I told them to upload all files and we would add the metadata tags through the datasheet view. NOT! That did not work and we also got a readonly message. Embarassing… So well sorry, you will have to edit the files one by one. Well that is not a realistic scenario. Then the column filtering was messed up, it is not possible to filter on metadata tags that are cascaded. And also, in the datasheet view the values have got a number and a hashtag in front of the value.

And yes, I know that managed metadata is very useful for many other situations, but when it comes to using it in libraries where you need to frequently update metadata tags, then it is not useful.

Please send me all your argues to convince me that I am wrong!! Because I really like the concept of managed metadata.

Share this blog post:

SP1 and June CU installed

Always a challenge to install service packs, and today (after having a snapshot of my new SP installation) I installed, in the following order:
SP Foundation SP1, reboot
SP Server SP1, reboot
Run Config wizard, reboot
Restart USP – worked (but you need to have the farm admin account in Local Admins group)
New snapshot
CU for Foundation, reboot
CU for Server, reboot
Run config wizard
Config wizard failed
Powershell and force upgrade
Config wizard successful
USP – failed to start the service
Knew it!
Found that the FIM (Forefront Identity Manager) groups locally were empty
Added the farm admin account to those groups
Now the USP started
Could run the full sync again
Imported all profiles and imported the AD pictures (thumbnailPhoto property) as well, nice!
Will try to remove the farm account from the local admin group tomorrow and run a full sync
Then find out which of the FIM groups the farm account needs to stay in, one by one
New snapshot
Not too bad.

Share this blog post:

Unattended service account

I have setup a new SP 2010 server farm this week, and it all went very well actually. But if you use the correct account settings and configure most of the things manually (like the dreaded UPS) then everything should work just fine. There are some messages in the Health Analyzer that needs to be taken care of though, unless you’ve done this a couple of times. You’ll learn 🙂 One of them is if you create some of the service applications that are dependent on the Secure Store, for instance Performance Point or Visio. Then you need to setup an unattended service account.

The warning in Health Analyzer:

If you click on that warning, the following message is displayed:

Go to your Service applications, click on “Secure store service”:

You’ll get a message saying that you have to generate a key:

Look in the ribbon right above the message, and you have a button called “Generate new key”:

You are prompted to enter a passphrase (this will be used for adding new secure store service servers or if you need to restore this service):

Then you are told that there are no target applications in this service, no shit! Let’s create one then 🙂
Click on “New” in the ribbon:

Now add the name of your target app id, for instance “Visio” or maybe the name of your external data source, add a Display name, contact email, target application type (which decides HOW your users should authenticate – as them selves or as a group, I selected “individual”) and then just click “Next”:

Add the account name and password that connects to the external source. The “masked” means if you wish to mask the characters, and of course we want that for the passwords. Click “Next”:

Add the adminstrators of this target application and you are done!
But, later you also need to “Set” the credentials of the users who should have access to this secure store:
Share this blog post:

Tack släkten!!

Igår var släkten här och firade, vi hade supertrevligt och dom sista nattsuddarna åkte taxi hem runt midnatt. Tack för alla fina lyxiga presenter, mycket mycket uppskattade!! Kvällen gick så jäkla fort, och mitt i allt kom det ner tre coola Falun grabbar som skulle hämta min lilla Toya… så nu är bilen såld och saknad :=). Om växeln jag fick har täckning så sålde jag den för 140.000 – annars så har jag fått 10… för det fick jag kontant hehe. Men jag känner mig lugn, det var supertrevliga killar som har kört 120 mil för att hämta en bil genom ett snöigt Dalarna ner till ett soligt Småland. Hoppas allt gick bra på hemresan, den var nog inte klar förrän 4 imorse!
Tillbaka till kebabtallriken och soffan, kram!!

Share this blog post:

Tack tjejerna!!

Var bara tvungen att klämma in följande meddelande trots att jag inte bloggar längre 🙂
Nu har presentkortet från Skansen kommit, tack snälla ni!! Jag ser verkligen fram emot vårt besök där! Stora kramar till er 🙂

Share this blog post: