Fear and Loathing
Gonzo blogging from the Annie Leibovitz of the software development world.
-
No post back Web Part connection using the DataSheet View
Maybe you haven’t seen this trick before so I figured I would serve it up to you for a weekend thing to try. Create a DataSheet view of two lists and with some field to connect them together, drop them onto a page and add connection information to link the fields together. You’ll have a dynamic view that doesn’t post back to the page and filters information from one list to the other like this:
Normally when you connect two Web Parts together (say through an ID field of some kind) you’ll have a radio button on one that, when clicked, will cause a post back to the page and filter the second list. Here we’re doing the same thing but instead of using the Standard SharePoint view, we’re using a DataSheet View.
I created two lists (by exporting the Northwind from Microsoft Access to a SharePoint site, another trick that you can do if you want some quick data), one for Suppliers and one for Products. The Products list has a column called SupplierID which matches the ones found in the Supplier list. Then I created two DataSheet Views for the lists and put them on a Web Part Page (in this case, the home page). Note that your clients will need Office 2003 installed in order to view this.
Connect the two lists as you would normally, having Products provide a row to Suppliers via the SupplierID column. That’s all there is to it. Now when you select a Supplier from the list, it filters the available Products. No post backs, no fuss. Give it a try with your lists.
Enjoy!
-
Leverage what you have, it really does work
Almost every day you'll find people complaining about SharePoint and how it doesn't do something exactly the way they want, or it's complicated to use, blah, blah, blah, blah, blah. This is pretty much true of any technology and yes, with enough time/money/resources anything is possible. Don't like what SharePoint does with Grouped Listings? You're welcome to write your own Web Part from scratch because you want the icon on the left instead of the right. Is it really worth it? I seriously doubt it.
SharePoint is a mish-mash of technologies and comes at a price of a pretty steep learning curve. A SharePoint guru needs to know all about the product in order to really know how they can exploit it. If you don't know all the features of a DataView Web Part (and there are many) then how can you dismiss it when you're looking for a solution? In addition to just knowing the product, you really need to know Windows infrastructure, Windows Server, IIS, Active Directory, DNS, SQL Server, and the list goes on. Now you don't need a deep understanding of all of these technologies but you certainly need some familiarity with most of them (and having a good breadth with 1 or 2 topics covered in depth is a good rounding of knowledge when it comes to SharePoint).
For example I was challenged with creating a news archive web part which allowed a user to browse all news items in the system, select a year, then filter by that year. All news items live as listings in SharePoint and you can just target the top level area to start getting listings for, recurse through them and put together your collection of information and present it. This is neither rocket nor science, at any level. However the implementation of the system was that they chose not to use the OOTB news areas, but rather created a custom area and all news items were entered manually (in a Document Library using the Web Part Page template) and listings were added manually (and then repeated on the Home Page to display the content again). This was all apparently done because someone didn't like the way news was entered and wanted more flexibility. True, you have a lot of options when you use a Web Part Page and a Content Editor Web Part, but is it really worth all that hassle? Using the built in news area and news feature of SharePoint Portal Server, it's a one step process. Click "Add News", enter your text (or link to an external news item) and save. The process the users go through now is about 10 steps involving a lot of duplication of information and manual editing of links (which can [will] lead to broken listings at some point).
Bottom line:
- Learn the technology platform you're working with and what it has to offer. Assume it works as expected (after all, you paid for it and it should) but do small technology spikes if it's a feature you're unfamiliar with (for example if you've never done a CAML query in code before try it before you offer that as a solution to building a White Pages system).
- Experiment yourself before you go into the meeting to discuss what the user needs so you know your boundaries
- Only build what you need. It's great to provide a system that has all the bells and whistles, but you'll find yourself quickly creating work for youself and makes your solution more complex than it needs to be and features that the end-user, while they may appreciate it, not really use in the end.
- Be the customer. If a solution smells complicated to you, walk through a scenario from their shoes and if you're frustrated doing it then they'll probably be too.
- Clearly set expectations with your customer on what they're getting and provide options (options always come at a cost but generally there are many ways to present information with OOTB features in SharePoint)
- Get buy in from as many levels as you need and flag things early and often if they look like an oddball solution to you (which in the long run will end up costing more when you keep revisiting it to fix things)
- Don't paint yourself into a corner and deliver a "Quick Hit" if you know you're going to be going back and fixing/rewriting/changing it entirely. While we can't read the minds of end-users, we can (if we're good enough) anticipate their needs and have alternate plans to back out if things get too complicated.
-
Hello to the Saskatoon and Regina user groups!
I had a fun time tonight presenting (via Live Meeting, thanks to Dan!) a level 100 session on developing for the SharePoint platform to the Saskatoon and Regina .NET User Groups. It was a great webcast with a good turnout and we have an advanced session coming up on Thursday night that will get into all the nitty gritty details of Web Part Connections and Code Access Security.
If you have a user group and are interested in having your friendly neighborhood MVP (that would be me) blather on about SharePoint over a phone call and Live Meeting presentation, let me know.
BYOBA*
*Bring Your Own Balloon Animals
-
Those crazy Germans and their SharePoint templates
By way of Michael Greth, those crazy Germans they hosted the first SharePoint Conference in Munich this week with more than 500 attendees. Michael presented 15 new site templates that were created by Microsoft Partners and customers from Germany. These templates were created during a competition called “SharePointChallenge 2006” and there’s a whole schwack (is that a word?) of them. First, before you all go frothing at the mouth they’re in German. Second, some require extra Web Parts to be installed and setup for them to work (don’t worry, free ones – I think). They are however a great collection of templates for Windows SharePoint Services and again, really show off what can be done with the little tool that could.
What’s great here is that there’s so much diversity. Bug tracking, a Library template for managing books and eBooks, CRM, Project Management (conforming to PMI standards and the Microsoft Solution Framework), Class scheduling, Travel expenses, and more. There’s even a template for tracking a football league with participant administration, play results, and evaluations. Some of these templates also have full documentation and information on their use.
Some are very imaginative in how they are designed and you can utilize these concepts for your own needs (yes, even though they might be in a foreign language for some). So check them out here to download them. They also have a live online demo system here with each template setup so you can give them a test drive yourself. This is great stuff and I can’t stress how important examples like these are needed to show how SharePoint isn’t just a document repository. I really hope someone (not me) would put forth the effort to translate these to English (hint, hint) as I’m sure a lot of people could find them useful.
-
It's official
Start making room for the new Microsoft Office 2007 System line of products. MS announced the “official” name which replaces Office 12 (and all the other names we’ve been using) in a press pass today. This includes Office SharePoint Server 2007 (which merges SPS and CMS together) and the new Microsoft Office SharePoint Designer 2007, which is partially based on Office FP 2003 and will be the tool for building SharePoint Web Sites. Check out the full press release here.
-
To Dispose or Close, is there a difference?
I’m in the giving mood tonight so figured I would fire off one more post before I hit the sack. Last Summer Maurice Prather wrote an entry about when to use Dispose (and leveraging the using clause). This also led to a KB article about this, so check it out if you’re interested.
One thing that a few people have asked me is what’s the difference between calling Dispose or Close? Various blogs mention using either but is there a difference when it comes to an SPSite or SPWeb? Yes, there’s a difference so now that you’ve decided to use Dispose/Close to dump your objects, which one should it be?
Dispose is a virtual method on both the SPSite and SPWeb classes. That means you can override it and, in turn, call the base class if desired. Let’s say you have a complicated setup where mutiple webs are connected, or perhaps you’re calling an external web service. You could subclass SPWeb into your own class and have it handle those external connections. Then in your own SPWeb class you would override Dispose, clean up any external connections and extra stuff you have, and then call the base implementation of Dispose (which just in turn calls Close). Or you could call Close yourself in your own Dispose method. The Close method on the other hand is not virtual so you can’t override it. It’s the one that actually does the final cleanup for an SPWeb and SPSite object.
So basically, if you’re creating your own SPWeb or SPSite sub-class (and you’re perfectly okay to do this) and have to do extra cleanup that the base class wouldn’t know about (maybe connections to a SQL database, but not the SharePoint one right…) then override Dispose, do your stuff, and call the base implementation. Otherwise if you’re just using the classes normally you can call the Close method directly.
P.S. I would provide code for this but my plugin is broken for some reason (I blame my IE7 fiasco) but you guys are smart so you’ll figure it out.
-
TDD and SharePoint
Chris Chapman has been blogging the past couple of days about using using TDD, NUnit, and SharePoint together. Chris follows some of the very same technique I do (or maybe I’m following him, who knows) as I have my [SetUp] and [TearDown] methods create SPWeb and SPSite objects for use in the tests (although I don’t use a base class for this, but it’s a good idea). As this is something I’m very passionate about (I’m giving a presentation about it at SharePoint Connections in April) it’s great to see people blogging about it and showing that TDD can be done even in that complicated, crazy environment we call SharePoint. So check it out.
-
Plumbers @ Work Podcast: Episode #3 - Powered by Infinite Improbability Drive
Our latest podcast is now online at Plumbers @ Work. We’re just belting out the episodes now that John isn’t traveling the globe pimping Visual Studio anymore. Episode #3 is up and running along with an upgrade to Community Server 2.0 which has a better look and a lot of cool features (perfect for our 3 listeners to play with).
Here’s the show notes from this episode:
- Introduction
- Around the Horn with the Plumbers
- Security March with Dan Sellers
- Microsoft Blacklisted C++ Libraries
- SHA-1 Discussion
- Team Foundation Server (TFS) Release Candidate (RC) 1
- Public Release of Internet Explorer (IE) 7.0 Beta 2
- Various Issues with IE 7.0 Beta 2
- Development of IE versus Development of Firefox
- The Browser as a User Experience (i.e. AJAX)
- Really Simple Syndication (RSS) in IE 7.0 and Outlook (AKA, The Ultimate Pull Application)
- Information Overload (AKA, Organizing Information)
- Upcoming Canadian Conferences: VSLive! and DevTeach
- Half-Time
- .NET Framework 2.0 Adoption
- ASP.NET 2.0 Adoption
- PetShop 4.0 Discussion and Highlights
- .NET Nuke 4.0
- Old Microsoft Reference Applications (AKA, "Different Strokes" or "ALF")
- Enterprise Library 2.0 Highlights
- Windows "Live" Highlights (i.e. Domains, Favorites, and Messenger)
- Other "Live" Projects (Office "Live" and Visual Studio "Live")
- Windows OneCare Beta
- The Realities of a "Secure" Operating System
- Windows Vista Favourite Features
- Running as Standard User/Non-Admin on Windows Vista
- Event Viewer in Windows Vista
- Windows Calendar (WinCal) in Windows Vista
- What's Coming Up for the Plumbers
- Upgrading to Community Server 2.0
- John (and Bil for that matter) Still Doesn't Have a Xbox 360
Running time for this show is 1 hour and 10 minutes. You can download the MP3 here on the files page (33.5 MB) as it hasn’t updated on the Community Radio at MSDN Canada site yet.
Enjoy!
-
Followup on Setting up your Development Environment
I stumbled across a new post by Maurice Prather over at Bluedog Limited which I wanted to comment on here (and I’ve left a similar comment on his blog). His concern was with my post about setting up your virtual development environment. The issue was regarding the part around changing “WSS_Minimal” to “Full” in the web.config file. Like he mentioned in an earlier post, this isn’t required for debugging to work nor is it a recommended practice in your shop.
I personally use it in my own development spaces only but what I neglected to mention was that a) I have another VM which is setup with “WSS_Minimal” as the trust level and b) doesn’t have Visual Studio, etc. installed. I use this VM for testing Web Parts before I release anything to anyone for testing externally (either publically or to my clients development/testing environments). With this setup, I also have to setup the policies on Code Access Security for any Web Parts. This isn’t a trivial thing to do but it’s also neither rocket or science.
The point of my article was about getting a development environment up and I personally don't consider it lazyiness if your dev enviroment is running full trust. Yes, if that's *all* you do then it's being lazy and maybe I've set a bad example but let's be honest here, do you really want to go through the issue of creating the web.config entry for every single web part you create? (grant you, not every web part might need that but there’s probably something you need to do for most).
Another thing that I lean towards in this development environment is one of presentations and just rattling off a quick web part to test a technology spike. As an example, sometimes I need to quickly create a Web Part so I:
- Create a new Web Part project
- Write the minimal amount of code I need to get my spike results
- Compile
- Install with the InstallAssemblies tool
I can have a working web part up in a minutes which for me is key when you're either showing someone something or just need a quick hit to figure something out. To spend time on CAS for a web part I’m going to throw away is probably too much time that I don’t want to waste (especially if someone else is paying for it). For me (and again, this is my preference) I would rather deal with security (and other SharePoint-y type stuff that can be fixed with configuration) in a test environment.
Having said all that basically you should read up on Code Access Security and Web Parts as there’s a lot out there and it’s important stuff so bottom line, don’t run as “Full” trust in web.config for your SharePoint environments.
One more thing that might make life easier (although I’m not sure yet). I finally got around to playing with CodeSmith that I picked up awhile ago. I’ve always seen it as a generation tool for creating your Data Access Layer (from a SQL or Access database) and I’m not one for code generation tools. There are some more advanced examples like the .NetTiers templates, which generates a fully commented and unit tested DAL from a database but one of the really cool thing you can use CodeSmith for is just generating repetitive code. I’ve always had to create things that are repetitive like strongly typed collections for business objects. It’s not a lot of work, but redundant and always the same thing. With CodeSmith you can get it to do the work for you (like a really uber-geeky macro). There’s also the ability to tie in a code-behind page with your template so it got me thinking that you might be able to do something like point a CodeSmith template at your Web Part (or a CAB file) and generate all the CAS entries for your web.config file automagically. Well, it’s just a theory and when I find some time to investigate I’ll see what can be done.
In any case, thanks Maurice for this important aspect of SharePoint development that often gets overlooked.
Note: In addition to Maurices resources on Code Access Security, Bamboo has an in-depth PDF document here on pretty much everything you need to know (including the complete set of permissions) but were afraid to ask about CAS and SharePoint.
-
BrightWork Reporter for SharePoint
BrightWork has just launched BrightWork Reporter, a highly configurable SharePoint web part that can “roll up” data from every list and web on a SharePoint server and simultaneously display it in a view-like report. Highlights of this new product include:
- 16 highly configurable reports delivered right out of the box
- Ability to configure shipped reports without any programming effort and to easily create new reports
- Facility to email, print and export the generated reports to Excel
Click here for a 30 day free trial that includes:
- A fully functional test drive
- Free training and customer support
- Access to a gallery of 34 additional reports