Blog of an overweight SharePoint addict

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.

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.

Sun 5 Jul 09

Pre-populating the BDC item picker in an application page

Filed under: BDC, Programming, SharePoint, Uncategorized — Reginald @ 5:21 pm

Adam Toth wrote a very good article on his old blog about using the BDC Entity Picker in an application page. Click here for the article.

What Adam didn’t cover however is what happens if you want to pre-load that picker with some information. In my instance, I was copying a list item with BDC data in it and wanted to allow the user to view and change the selected BDC field.

It turns out that it wasn’t as difficult as I was expecting, and after some research in the SDK about the BDC Item picker I was able to produce the effect I wanted.

I’m going to assume that you’ve followed Adam’s guide thus far and have been able to get the BDC Itempicker on your page and have it talking properly to the BDC (E.g. you can search for an item and have it populate the picker.) If you haven’t got this far, go and do that first as it’s fundamental to what we’re going to do.

So in my scenario, The list item has a BDC field for Client name. The first thing that you need to understand is how SharePoint stores the BDC Field data in the SharePoint list. I was expecting to have a new field type to play around with, but No, it’s much easier than that, you get two strings. One for the display value and one for the Entity key.

In my BDC application definition, I have an entity called dbo.Customers and this has already been added to the list definition as a Business Data column. If you write a quick console application to browse through the field names, you’ll find 2 fields, one called “Client” frm the field definition in the list and one called “dbo_x002e_Customer_ID” (This latter one was added when the field was configured.)

So with the values of these two fields we can create a PickerEntity which can be understood by the BDC Itempicker.

The PickerEntity was declared earlier in the code and then is used as follows:-

if (item["Client"] != null)
{
    if (item["dbo_x002e_Customer_ID"] != null)
    {
        peClient = new PickerEntity();
        peClient.DisplayText = item["Client"].ToString();
        peClient.Key = item["dbo_x002e_Customer_ID"].ToString();
        bdcClientSelector.Entities.Add(bdcClientSelector.ValidateEntity(peClient));
    }
}

Hopefully this will help demystify the Itempicker a little..

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 23 Jun 09

Event Handlers from code.

Filed under: Programming, SharePoint — Reginald @ 8:17 am

Eek.. June already.. I’ve been on my hols, come back and realised that I’ve been somewhat remiss in posting to my blog.

So without further ado, I’ll talk about my current expedition into the realm of SharePoint code. Todays task is EventHandlers from code.

Attaching Event Handlers from code is pretty easy, the SDK shows various methods all of which seem to do the trick. However, I want my Event Handler to have a specific GUID as it’s ID. The idea behind this is that my management application knows what the different event handler ID’s are in all the environments.

And this is where my plan has currently fallen apart.

I’m using the following code to add the event handler (after correctly checking that an event handler of the same name and assembly doesn’t already exist of course..)

if (!itemDeletingExists)
{
SPEventReceiverDefinition deletingReceiver = erdc.Add(new Guid("F649A610-2C83-4f11-B73F-A7D1656DEACB"));
deletingReceiver.Name = "ResourceEventsItemDeleted";
deletingReceiver.Type = SPEventReceiverType.ItemDeleting;
deletingReceiver.SequenceNumber = 10000;
deletingReceiver.Assembly = assm;
deletingReceiver.Class = nsp;
deletingReceiver.Update();
receiverAdded = true;
}

When you step through the code above, the event handler is added quite happily and the deletingReceiver.ID = the guid used in the constructor.

So further down my code we grab the collection of event handlers currently held by the content type and sure enough, there is our (in this case 3 of them) event handlers, sitting happily in the collection.

However, if you grab the EventReceiverDefinition for each of them, the .ID is all zeroes… Is this a bug or intended behaviour? Further investigations ongoing..

Paul.

Thu 7 May 09

Using JQuery to remove Linked List Items Hyperlinks – Revisited

Filed under: JQuery, Javascript, Programming, SharePoint, Uncategorized — Reginald @ 11:36 am

So in an earlier post I talked about using JQuery to remove the A tag that is automatically included in the rendering of a linked list item in display mode.

I really liked this solution as it avoided having to go to the lengths of writing a custom field to solve this and can be targetted at a single page, or a whole site by embedding the code in the Master Page.

So, anyway, it’s worked quite nicely at the client that instigated the investigation, so I decided to re-use the code for a new client. This has functioned perfectly, right up to the point where they used a list view with a Group by in the selected view.

So, why does this cause different behaviour? Well the answer is in how the ListView web part handles the hiding and revealing of the grouped data. When you click on the expand link, the page performs a partial postback to SharePoint to get the missing data, before returning a block of HTML to display.

As this happens during the partial postback, the already registered code on the page doesn’t run a second time as the jQuery event $(document).ready doesn’t trigger again.

I tried various methods before placing a post on the EndUserSharePoint.com StumpThePanel Q&A forum in the hope that “JQuery in SharePoint” god Paul Grenier would be able to answer my timing issues, which he did very nicely!

So how did we resolve it.. The answer is to replace the MicroSoft function that handles the posted back data within the listview ExpGroupRenderData() with a JQuery version.

function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {
	$("#tbod"+groupName+"_").attr("isloaded",isLoaded)
		.html(htmlToRender)
		.show("fast",HideLinkedListItems());
}

HideLinkedListItems() is the previously created function to strip the A tag frm linked list items, wrapped in a function wrapper so that it can be called frm either the update, or the Document.ready as per the original post.

The result, expanding the listview now presents the list view items, nicely stripped of their links.

I hope this helps someone achieve the same..

Paul.

Wed 22 Apr 09

Overriding Core.JS functions

Filed under: Javascript, Programming, SharePoint, Troubleshooting — Reginald @ 2:30 pm

A client of mine recently required adding an additional E-Mail link adding to the Item Drop Down menu that drops off of the ECB menu within Document Libraries and Lists.

Now this functionality is provided by the function AddSendSubMenu(m,ctx) within Core.JS. Editing this file is NOT SUPPORTED (You all know this by now I’m sure!). So what to do? Well the answer is make use of Javascript’s natural override.. I.e. If you declare a function twice, the last declaration is the one that gets used.

So, Seems simple huh? We copy the function we want out of Core.JS and stick it into our own NewSendToMenu.js file in /TEMPLATE/LAYOUTS/1033

We then place a standard little script tag into the Head of the Master Page and bobs your uncle, the code gets loaded quite happily on each page.

Or does it? Well yes it does always get loaded.. I proved this by putting a document.write(”Hello World”) in front of the function and this got displayed every time without fail, And yet my customisations weren’t there.

I remembered reading somewhere that Core.JS has a habit of hanging around and getting executed last, My original method using the SharePoint:ScriptLink tag seemed to support this, so I dropped back to using the standard Script tags.. same problem though..

I then stumbled across a small article on the MSDN forums that pointed out the use of the Defer tag in the Core.JS script block. (You can see this if you view the page source in IE..) This means that the execution of Core.JS is deferred until the rest of the page is loaded, thus overriding my own override..

So the solution appears, Declare my script lower down the page than the Core.JS, and tag my Script block with the Defer option also.. This appears to execute my code AFTER core.js has completed.

Now, I’m not 100% how often this will be the case.. looks like this may need some load testing, but I think it’s fair to say that if one script is deferred higher up the page, than another lower down, they should be deferred into the same execution order that they met during page load?

Or am I being too simplistic? Never mind.. for now this works and resolves the client issue!

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>

Wed 4 Mar 09

SharePoint Dispose Checker Tool

Filed under: General, Programming, SharePoint, Visual Studio 2005 — Reginald @ 11:51 am

The Microsoft SharePoint team have released a SharePoint disposal checker tool to the MSDN community. This command line tool scans individual asseblies, or entire directory structures and analyses the code for memory leaks through poor disposal.

I ran it against some of my assemblies and I’m happy to say only my quick command line tools written for testing exposed any poor disposal issues.. (Mainly because I don’t bother worrying about disposal when I’m just testing constructs..)

The project site can be found here with further links to the team behind the tool.

http://code.msdn.microsoft.com/SPDisposeCheck

Reg.

Older Posts »

Powered by WordPress