Blog of an overweight SharePoint addict

Thu 29 Jul 10

Weird CQWP behaviour with custom user columns

Filed under: CQWP, General — Reginald @ 1:42 pm

So one of my colleagues approached me today with a problem he was having setting up a new content query web part for a client. it’s a fairly simple affair that just needs to pull together project statuses across a site collection. No cross site query issues, no custom field types to worry about.. Just a simple list.

Or so we thought, Try as we might we could not get two of the fields to return a value, BusinessOwner and ProjectManager. In the Content Type, these site columns are simple People or Group field types, set to display the name without presence.

Without any further ado I fired up my trusty development VM and started playing around to re-create the issue.

  1. Create a new content type based on the List Content Types/Item parent. published to Custom Content Types group.
  2. Added a new site column called GreenBanana to the new content type. This is set to be a People or Group column, with the additional settings of Not required, No multiselect,People Only, All users and show field as name (Subsequently tested with Name and Presence and no difference.)
  3. To simulate the nested nature of the query in the client environment, I create a new sub-site in my site collection, added a new list and configured this list to use the new content type.
  4. Create 2-3 new items in the list, ensuring that the GreenBanana field has a value of my test user configured.
  5. Back to the root site of the Site Collection, create a new content query web part on the page and set it up to retrieve the new content type frm all sites in the site collection. As expected, the 3 new items duly appear.
  6. Now we export the CQWP to point it at the custom XSL that I have prepared. In addition I’m adding “GreenBanana,Text; to the CommonViewFields property to make it available in the returned XML. (Note: I’m using Text not User as the field type.)
  7. Delete the original CQWP and upload my newly updated one.

The newly uploaded one shows me the 3 items that I expect, so modify shared webpart and point the item style at my showXML style. (Just a simple XSL that outputs all of the available fields and their values.)
The heading GreenBanana shows, but not value.
So, we’re at the stage that my colleague got to, No value in the custom site column based on the people type. Just an heading and an empty value.

P:GreenBanana
V:

So, thinking that I might be pulling an item frm somewhere else (despite this being a new content type) I decided to filter only on items that included me in the GreenBanana column.

P:GreenBanana
V:1;#Paul

Whoa.. Ok, why did that happen? It is definitely the same item that I had previously, but now I have a value. Setting the filter to be Show me everything where the GreenBanana column is not equal to Administrator shows me all three items AND their values.

Weird.. and at the moment I don’t have an explanation.

Paul.

So, why haven’t I posted in a while?

Filed under: General — Reginald @ 8:20 am

Well the main answer I guess is I’ve just been too busy. You’d think that with SharePoint 2010 now out in the wild that no-one would want to work with 2007 anymore? Well you’d be wrong, the vast majority of my recent work has been on firmly ensconced 2007 farms, but surprisingly a number of new 2007 installs too.

So, why build on 2007 when at the time, 2010 was just around the corner. The answer is experience. Clients know that SP2007 has bedded in now, It’s had two major service packs and lets face it, there are blog posts and support forums by the thousand out there for most major problems that you may come across. SP2010 on the other hand is the new kid on the block, It’s fresh faced, lively and you just known there’s going to be a dose of acne bubbling under the surface waiting to erupt. So I know a lot of clients are going to play a waiting game for SP2010 and let it settle in a bit to it’s new role.

And let’s face it, the upgrade support between 2007 and 2010 is far far better than the previous upgrade processes. Clients love the staged upgrade that can be carried out on their sites to minimise the impact to the look and feel for their users, who as we all know fear change immensely.

And on the subject of change, which has got me back onto my blog for the first time in ages, I’ve finally switched to a better blogging software, staying here on Wordpress, but using an off-line editor so that I can write these posts on the move. Hopefully this will make code snippets a lot easier to bring in-line and overall, encourage me to be a bit more forthcoming..

See you all soon.

Paul.

Tue 24 Nov 09

Should I change the name?

To once a month updates?

I haven’t stopped since I got back from SPC and have been dashing around between clients working on SharePoint 2007 issues. Doesn’t anyone understand I want to play with SharePoint 2010 now? Or more to the point, I need to upskill in some areas very quickly to get the most of SP2010 and all the goodness it brings.

Looking at whats coming in SP2010, I honestly think the IT Pro’s have got it easy.. You guys just have to learn one new application, Us Devs have to learn at least 2, SP2010 and Visual Studio 2010!

Then on top of that, we have an updated object model to contend with, along with a brand new object model in the form of the SharePoint Client OM!

Add to this the requirements to use XSLT for almost every list view in SP2010, SPLinq (Call it SPlinq, MS hate that!!), Silverlight and a lot more Javascript than before, all adds up to a lot of skill-up time!

So here’s to spending many evenings and train journeys in front of Visual Studio, playing with Silverlight 101 and all the new Sharepoint tools that now come out of the box with VS!

I’m booked up in December as solidly as November was, so i wouldn’t expect too many posts on here just yet, although I am planning to extend the piece I wrote on KPI’s to give more ideas and hopefully present on this at a SUG do in the early new year.

Regards

Paul.

Tue 27 Oct 09

And, that’s a rap!

Filed under: General, Programming, SPC09, SharePoint, SharePoint 2010 — Reginald @ 7:02 pm

Well the MS SharePoint 2009 conference is over and life is slowly returning to normal. A couple of days away from SharePoint to restore my equilibrium and I’m now back to SharePoint 2007 and the real world.

But what of SharePoint 2010? When can we see it in all it’s glory. Well Steve Ballmer announced that the Beta 2 release would be sometime in November as they were doing last minute testing internally in Microsoft. During the conference, all of the SharePoint web pages were switched over to the new version and reports coming out suggest no major problems. So fingers crossed for an early Beta 2 in November.

The conference for me was all about soaking up the changes to development in SP2010. I didn’t really focus on any of the admin sessions at all as I’m planning to download and watch them on my long journeys to work over the next few weeks. So what does SP2010 bring to us Devs?

Well the big story is the much improved integration with Visual Studio 2010. (Beta 2 available now) which ships with an absolute ton of SharePoint 2010 project templates from Web Parts to Event Receivers, List Definitions, Content Types etc.

And the biggest win for me.. ONE TOUCH DEPLOYMENT!! Yes.. hit F5 and your project deploys to your test server with nary a hiccup and just a minor bit of configuration during the project set-up. Gone are the days of configuring your DDF files and your WSPs (Well once we convince all of our clients to switch to 2010 that is!!)

So my top 5 improvements (i reserve the right to get more excited about others as time unfolds):-

  1. One touch deployment for testing
  2. Automatic creation of the WSP (This should encourage more solution deployments)
  3. Visual Webpart designers (Think using a User Control without needing Son of Smart Part)
  4. Content Types that can be deployed and updated
  5. Vastly improved Tableless design

Over the next few weeks I’ll be playing with Beta 1 with Visual Studio 2010 Beta 2 (If they play nicely together) and hopefully will be rearranging this list and probably expanding it. Beta 1 is still under NDA, so nothing that hasn’t been mentioned at SPC09 will be raised, but hopefully Beta 2 won’t be far around the corner.

Paul.

Tue 13 Oct 09

Tentative Schedule for SharePoint Conference 2009 – Las Vegas

Filed under: General, SPC09, SUGUK, SharePoint, SharePoint 2010 — Reginald @ 2:53 pm
Join me at SPC09

Twitter @Cimares

Ok, so Microsoft finally released the full session schedule during the last 24 hours and I’ve tentatively booked the sessions that I want to go see.. And this has to be subject to change because there are so many great sessions that i want to get into. Thank god Microsoft are going to provide an AV feed of all sessions within 48 hours of them finishing. Hopefully I can download these and watch them on the train into work during the following week.

So, here’s my current schedule..(Subject to Change.. Hastags for Twitter Search)

Saturday 17th

  • Arriving about 2:30pm PST
  • Gambling and trying to avoid jetlag! Probably joining @jthake somwhere in Vegas

Sunday 18th

  • Getting to see Vegas,
  • Catch the Formula 1 somewhere (#ShareF1)
  • 18:00 ish.. register then #SharePint

Monday 19th

  • 9:00AM – Keynote Speech – Steve Ballmer
  • 10:30AM – Keynote 2 – Jeff Teper
  • 1:15PM – Overview of the SP2010 Developer platform
  • 2:45PM – Visual Studio 2010 SP Development Tools Overview
  • 4:30PM – Developing with SP2010 Sandboxed Solutions
  • Evening – no idea yet..going with the flow.

Tuesday 20th

  • 9:00AM – Advanced Webpart development in VS2010
  • 10:30AM SP2010 based document assembley and manipulation using Word
  • 1:15PM – Authentication & Authorisation in SP2010
  • 1:15PM – Deep Dive Open XML and Open XML SDK
  • 2:45PM – SP2010 Upgrade part 1 – Fundamentals
  • 4:30PM – SP2010 Development Best practices
  • Evening – 80’s Beach party!!!!! and then #TweetupSPC09 if it’s still going on

Wednesday 21st

  • 9:00AM – Workflow development in SP2010 with VS2010
  • 10:30AM – Developing with the new User Interface features in SP2010
  • 1:15PM – Developing with REST and LINQ in SP2010
  • 2:45PM – Extending the VS2010 SP tools with new Designers
  • 4:30PM – Customizing the VS2010 Sharepoint deployment process
  • Evening – Jury’s out on this one.. might go watch #ShareHoldem

Thursday 22nd

  • 9:00AM – Load testing SP2010 with VSTS
  • 10:30AM – Deep Dive into SP2010 Profile Store and profile Data
  • 1:15PM – Application Lifecycle Management for Developers in SP2010
  • 2:45PM – Building rich dynamic websites with SP2010
  • Evening – #ShareHofBrau – Last chance to catchup with SP stragglers..

Friday 23rd

  • 16:40 Takeoff for London Gatwick!! (arrives 10:30AM!)

So all told a pretty rammed week.. But I’m REALLY looking forward to it..

Tue 6 Oct 09

Whats the record for the longest Calculated SharePoint column?

Filed under: Calculated Fields, General, SharePoint — Reginald @ 3:28 pm

Well my longest to date is 304 characters.. I’m not quite sure what the SharePoint limit is, but here’s mine…

=IF(LEN(MONTH(Dated)/3)=1,TEXT(Dated,”mmm-yy”),IF(LEN((MONTH(DATE(YEAR(Dated),MONTH(Dated)+1,DAY(Dated))))/3)=1,TEXT(DATE(YEAR(Dated),MONTH(Dated)+1,DAY(Dated)),”mmm-yy”),IF(LEN((MONTH(DATE(YEAR(Dated),MONTH(Dated)+2,DAY(Dated))))/3)=1,TEXT(DATE(YEAR(Dated),MONTH(Dated)+2,DAY(Dated)),”mmm-yy”),”ERR”)))

“And what pray, does that monstrosity do”, I hear you ask…

The answer is, it simply works out which quarter of the companies financial year the item appears in. The list item has a column called Dated which is a date only field.

Our financial year runs 1st Oct to 30th Sept with each quarter ending Dec,Mar,Jun,Sep.

In order to work out which quarter the item is in, I’ve nested 3 IF’s together.. If you’re not familiar with how the =IF function works in a calculated column, then it breaks down like this..

=IF(jonnysapples > janesapples,”Jonny has more apples”,”Jane has more apples”)
=IF(SOMETHING TO TEST) , DO THIS FOR TRUE , DO THIS FOR FALSE)

So in this instance if the column named Jonnysapples does indeed have more apples in it, then the phrase “Jonny has more apples” will be displayed in the resulting column. If it doesn’t, then “Jane has more apples” will be displayed.

Excellent.. So now what we want to do, is replace the output statement for FALSE (”Jane has more apples“) with the next test to see if Jonny is unhappy.

e.g.

=IF(jonnysapples > janesapples,”Jonny has more apples”,IF(jonnysmoney>0,”Jonny doesn’t care as he can buy some more”,”Jonny is upset because Jane has more apples”))

So, working the logic through,if Jonny has more Apples, we’ll see “Jonny has more apples“, if he has less, but some money (After checking the money column), then we’ll see “Jonny doesn’t care as he can buy some more” and then finally, if Jonny has less apples and no money, We’ll see the final state of “Jonny is upset because Jane has more apples

So now we’ve implemented a 3 state result. By nesting a further if statement we’re able to twist this solution to our means.

So now we need to look at what logic we’re actually implementing in each of the IF statements.If you extract the “Something to test” part out of the first statement you’ll see:-

LEN(MONTH(Dated)/3)=1

Now if you bear in mind that the months that represent our year quarter period ends are all a factor of 3, then it starts to make sense. (Sept – 9th Month, June, 6th Month etc) Take the numeric value for the month. if you divide it by 3 and get a whole number e.g. a result with a length of 1, then we’re in a month divisible by 3. if we get any form of decimal, then we’re not.

=IF(LEN(MONTH(Dated)/3)=1,TEXT(Dated,”mmm-yy”),”DO THIS FOR FALSE”)

So if the month can be divided by 3 without any decimals, we’ll output the Dated column, formatted to look like mmm-yy. If it can’t then we’ll step into the next if statement in place of “DO THIS FOR FALSE”.

Again, very similar logic, however this time, we’re going to add 1 month to the date in Created and test that..

IF(LEN((MONTH(DATE(YEAR(Dated),MONTH(Dated)+1,DAY(Dated))))/3)=1,

If that results in a whole number, then we’ll output the Created+1 month using TEXT(DATE(YEAR(Dated),MONTH(Dated)+1,DAY(Dated)),”mmm-yy”),

And if it doesn’t? Yep you guessed it, we step into the third and final IF statement which we know is going to be true because the 4 month will divide by 3 once again. However to keep the parser happy, we’ve got to have an option of something to output for False, so that’s where you’ll see “ERR” in the formulae.

If this has worked, all you’ll see in your calculated column is Sep-09,Dec-09,Mar-10,Jun-10 etc….

This solution might not work for your if you use a different financial year and quarters, but the principal is sound..

Regards

Paul.

Mon 5 Oct 09

Weekly Access problems to a SharePoint site

Filed under: General, IIS, Troubleshooting — Reginald @ 9:11 pm

Just recently a client of mine raised an issue regarding an access issue that seemed to raise it’s head about every 8 days or so. What struck me was the distinct lack of errors issues by the system.

Approximately every 8 days, users will go to use the site and get a failed to connect to site error. IISReset and AppPool recycles don’t resolve the problem, and only a reboot of the Web Front End resolves the issue.

IIS Logs just show connections stopping at a fixed time and the SharePoint logs show nothing other than the usual trace log messages around timer jobs and index crawls.

It wasn’t until I examined the HTTPERR log file (Located normally in C:\windows\system32\logfiles\HTTPERR) that I realised what was likely to be happening as it was showing Connection Refused.

2009-10-02 10:59:07 – - – - – - – - – 2_Connections_Refused -
2009-10-02 10:59:13 – - – - – - – - – 1_Connections_Refused -
2009-10-02 10:59:17 – - – - – - – - – 2_Connections_Refused -

Basically, all incoming connections to a web server are handled by the HTTP.SYS portion of the system before being handed out first to IIS and then to the respective handler for applications such as SharePoint. Hence the distinct lack of error logs in IIS and SharePoint.

This system process utilizes Non Paged Pool memory extensively, however it has a little known security feature that starts to refuse connections once there is only 20Mb remaining in the NPP.

At this point it’s important to remember that HTTP.SYS is not the cause of your problem, merely a symptom of a system with potentially a few things wrong with it. So how do we trouble shoot this little problem on a SharePoint WFE.

So the first place to check is how much NPP memory you have available to you. A Windows 2003 32 Bit server should have 256Mb of NPP available at boot. However if for some reason you have the /3GB switch specified in your boot.ini, this NPP allocation is halved to 128Mb. In addition, the /3Gb option is NOT SUPPORTED for SharePoint and must be removed. (KB933560)

So at this point we’ve doubled the NPP available to us, but this may not have solved the problem as something else is in process taking that memory and possibly leaking it away by not returning it properly to the pool. In these instances you need an application called PoolMon.exe from the Windows Server 2003 resource kit.

Using this tool it is possible to identify the driver or system file that is not returning memory properly to the NPP, which in my case was down to an old Broadcom Ethernet driver for the Dell PowerEdge server this system was running on.

I won’t re-create the posts on how to use the Poolmon tool as there are some good ones out there, but the MS articles that show you how to use the PoolMon.exe program are below.

KB177415 – How to use Memory Pool Monitor to troubleshoot Kernal mode memory leaks.

On a side note, if you have Windows 2003 SP2, then you may need to think about disabling the TCP Chimney as per KB945977

Hope this helps you some way to resolving a similar issue.

Paul.

Mon 10 Aug 09

Eeek.. slacking again..

Filed under: General, Programming, SPC09, SharePoint, SharePoint 2010 — Reginald @ 3:48 pm

Yes it’s nearly a month since my last confession again… And a busy one at that…

Shortly after the first videos were sent out by Microsoft, my company got accepted into the early adopters program, and also the Technical Beta!!

So now, I have to squeeze in some time to start writing new articles on SharePoint 2010 in readiness for publication on the day the NDA is lifted.. which I predict will be around the start of the SharePoint conference in Las Vegas on Ocotober 19th which I’m very pleased to be able to say I’m attending!! I sorted out my registration this afternoon, with flights and hotels to be booked this evening..!!

But before all this happens, I have to finished these confounded event handlers on a list with Item approval.. watch this space.

Paul.

Fri 26 Jun 09

Event handlers from code – redux!

Filed under: General, Programming, SharePoint — Reginald @ 8:20 am

Ok, well I think I’ve worked out why the GUId isn’t getting defined.

The code I’ve written creates an EventHandler on the base content type. When this content type gets assigned to a library, the content type is instanced to the library and as a result I think the GUID i assign is removed.

I think were I to assign an event handler directly to a list, then this wouldn’t be the case and I could give a GUID in the creation method.

I’ve not tested this yet, but it seems to make sense.

Paul.

Tue 14 Apr 09

Using JQuery to remove Linked List Items hyperlinks.

Filed under: General, JQuery, Programming, SharePoint — Reginald @ 2:30 pm

A client of mine recently raised a concern about the linked list items that are used within SharePoint. In the display list view, they show up as hyperlinks to the linked item. All well and good, you can click on these links to see the full item, however there is no easy way to return as when you click on close you are sent to the default view for the list the linked item belongs to.. (Still with me?)

We discussed several ways around this, but the feeling from the client was that they didn’t want to see these links anyway, so removing them would be the best solution. (I did suggest creating a whole new field type with the option to turn off the Hyperlink in the display render, but they felt that was overkill)

Having played with JQuery, I was pretty certain that we could override the default behaviour using a simpler jQuery selector.. But what do we select?

Well the Linked List items very handily all have the term RootFolder=* in their URL. No other link in SharePoint appears to have this and certainly my testing hasn’t thrown up any errors yet!

So, how do we remove this link in jQuery? Well the trick is to return a collection of A tags that have an Href containing the pattern “RootFolder=*”. Once we have this, we simply add a sibling node using the .After() function to create a new span tag, and then copy the previous tags text content into the new tag, before hiding the A tag using .Remove()

It sounds very simple and it is, but as I found during this exercise, the secret is getting your selectors spot on and making sure the code is firing properly!

Paul.

Note: You will need to have downloaded the JQuery library and registered it in the masterpage, along with the code below (Which can either go in a Content Editor Web Part, or be placed in the Masterpage itself if you want to affect every page.)

<script type="text/javascript" src="/jquery-1.3.1.js"></script>
 
<script type="text/javascript">
$(document).ready(function() {
$('a[href*="RootFolder=*"]').each(function(index) {
var link = $(this);
$(this).after("<span>" + link.text() + "</span>");
$(this).remove();
});
});
</script>
Older Posts »

Powered by WordPress