Paul's profilePaul Galvin's SharePoint...BlogListsSkyDrive Tools Help

Blog


    December 31

    Thinking About Commercial Products

    I put up a SharePoint Designer extensions project up at CodePlex earlier this year and even though it's really quite limited in scope, I estimate that it's been downloaded by 40 to 60 (possibly even 100) companies in just about two months.  That indicates to me that there's a market for that solution and if I were to successfully commercialize it, that could translate into a goodly amount of beer :)

    My background is actually much more in product development and I know what is required to bring a top-notch product, as opposed to a CodePlex hobby project, to market.  In my past life, I was responsible for product R&D for all software products.  The difference between then and now is that I'm a consultant now working for an (excellent) consulting firm (Conchango).  Previously, I had an entire company behind me and in front of me, selling and supporting the products we brought to market.  Today, I'd be alone.

    I have several product ideas in mind, but I think the easiest would be to create a commercial version of the above-mentioned CodePlex project that uses that as a starting point and extends it further.  My fuzzy off-the-cuff thinking is to charge something like $100 for an unlimited developer license and $500 per production web front end.  I think I would also give away the source code.

    If you have thoughts or experiences that you're willing to share, please leave a comment or email me directly.  I'd like to hear opinions like:

    • Is it all worthwhile?
    • Practical suggestions for marketing, collecting money, distributing.
    • Pricing.
    • Support.
    • Any other comment you'd like to leave.

    It's "easy" to come up with product ideas and to implement them, though many dozens of hours of work are required.  The other stuff is not as easy for me.

    </end>

    Technorati Tags:
    December 30

    Sunday Morning Funny: "Jesus Must Die"

    We bought our first (and only) "luxury" car back when hurricane Floyd nailed the east coast of the U.S.  We got a LOT of rain here in New Jersey and several days passed before life returned to normal.  Just before Floyd struck, we made an offer for a used Volvo 850 GL and after Floyd struck, drove it home.

    It was our first car with a CD player.  Like most new car owners, we went a little CD crazy, revived our dormant CD collection and went on long drives just to listen to CD's in the car.  Like all fads, this passed for us and we ended listening to the same CD over and over again.  In our case, it was Jesus Christ Superstar

    One of the (many) brilliant pieces in that rock opera is sung by the establishment religious types, led by Caiaphas, the "High Priest".  They sing their way into deciding how to handle the "Jesus problem" and Caiaphas directs them to the conclusion that "Jesus must die".  The refrain on the song is "Just must die, must die, must die, this Jesus must die".  You hear that refrain a lot in that piece.

    At the time, my son was about three years old.  You can probably see where this is going. 

    I came home from work one day and my son is in the living room playing with toys and humming to himself.  I'm taking off my jacket, looking through the mail and all my usual walk-in-the-door stuff and I suddenly realize that he's just saying, not really singing: "Jesus must die, must die, must die."  I was mortified.  I could just see him doing that while on one of his baby play dates at a friend's house -- probably the last play date with that baby friend.

    We pulled that CD out of the Volvo after that :)

    </end>

    Technorati Tags: ,
    December 27

    Google Did Accept My Live Spaces Blog Into the AdSense Program

    UPDATE: As of 03/09, I have found no way to integrate my live spaces account with Google Adsense.  Microsoft's system here seems to prevent all of the technical mechanisms that Google provides would-be adsense hosters.  I tend to believe this is mainly a side effect of the security they've built into live spaces, not a direct effort to disable Adsense. 

    This is not a SharePoint post, but might be of interest to bloggers generally.

    Someone commented on their Windows Live Spaces blog that Google affirmatively denied their application to participate in AdSense.  She theorized that Google denied her because Windows Live Spaces hosts her blog. However, I was recently accepted into the program for my live spaces blog, so the policy has either changed or Google denied her for some other reason.

    Of course, I don't see any obvious way to integrate Google AdSense into my live space, but it's a start :)

    </end>

    Technorati Tags: ,
    December 24

    Implementing Master / Detail Relationships Using Custom Lists

    Forum users frequently as questions like this:

    > Hello,
    >
    > Please tell me if there are any possibilities to build a custom list with
    > master and detail type (like invoices) without using InfoPath.
    >

    SharePoint provides some out of the box features that support kinds of business requirements like that.

    In general, one links two lists together using a lookup column.  List A contains the invoice header information and list B contains invoice details.

    Use additional lists to maintain customer numbers, product numbers, etc.

    Use a content query web part (in MOSS only) and/or a data view web part to create merged views of the lists.  SQL Server Reporting Services (SRS) is also available for the reporting side of it.

    However, there are some important limitations that will make it difficult to use pure out-of-the-box features for anything that is even moderately complex.  These include:

    • Size of related lookup lists vs. "smartness" of the lookup column type.  A lookup column type presents itself on the UI differently depending on whether you've enabled multi-select or not.  In either case, the out-of-the-box control shows all available items from the source list.  If the source list has 1,000 items, that's going to be a problem.  The lookup control does not page through those items.  Instead, it pulls all of them into the control.  That makes for a very awkward user interface both in terms of data entry and performance.
    • Lookups "pull back" one column of information.  You can never pull back more than one column of information from the source list.  For instance, you cannot select a customer "12345" and display the number as well as the customer's name and address at the same time.  The lookup only shows the customer number and nothing else.  This makes for an awkward and difficult user interface.
    • No intra-form communication.  I've written about this here.  You can't implement cascading drop-downs, conditionally enable/disable fields, etc. 
    • No cascading deletes or built-in referential integrity.  SharePoint treats custom lists as independent entities and does not allow you to link them to each other in a traditional ERD sense.  For example, SharePoint allows you to create two custom lists, "customer" and "invoice header".  You can create an invoice header that links back to a customer in the customer list.  Then, you can delete the customer from the list.  Out of the box, there is no way to prevent this.  To solve this kind of problem, you would normally use event handlers.

    It may seem bleak, but I would still use SharePoint as a starting point for building this kind of functionality.  Though there are gaps between what you need in a solution, SharePoint enables us to fill those gaps using tools such as:

    • Event handlers.  Use them to enforce referential integrity.
    • Custom columns: Create custom column types and use them in lieu of the default lookup column.  Add paging, buffering and AJAX features to make them responsive.
    • BDC.  This MOSS-only feature enables us to query other SharePoint lists with a superior user interface to the usual lookup column.  BDC can also reach out to a back end server application.  Use BDC to avoid replication.  Rather than replicating customer information from a back end ERP system, use BDC instead.  BDC features provide a nice user interface to pull that information directly from the ERP system where it belongs and avoids the hassle of maintaining a replication solution.

      BDC is a MOSS feature (not available in WSS) and is challenging to configure. 
    • ASP.NET web form: Create a full-featured AJAX-enabled form that uses the SharePoint object model and/or web services to leverage SharePoint lists while providing a very responsive user interface.

    The last option may feel like you're starting from scratch, but consider the fact that the SharePoint platform starts you off with the following key features:

    • Security model with maintenance.
    • Menu system with maintenance.
    • "Master table" (i.e. custom lists) with security, built-in maintenance and auditing.
    • Search.
    • Back end integration tools (BDC).

    If you start with a new blank project in visual studio, you have a lot of infrastructure and plumbing to build before you get close to what SharePoint offers.

    I do believe that Microsoft intends to extend SharePoint in this direction of application development.  It seems like a natural extension to the existing SharePoint base.  Microsoft's CRM application provides a great deal of extensibility of the types needed to support header/detail application development.  Although those features are in CRM, the technology is obviously available to the SharePoint development team and I expect that it will make its way into the SharePoint product by end of 2008.  If anyone has an knowledge or insight into this, please leave a comment. 

    </end>

    December 21

    Quick Tip: Content Query Web Part, Lookup Column Value and XSL

    I have a column name in a content type named "Real Estate Location".

    That column is of type "lookup".

    I have modified <CommonViewFields> and ItemStyle.xsl to show the column.

    A simple <xsl:value-of select=...> returns back an internal value that includes ordinal position data, such as:

    1;#Miami

    To get the human-friendly value, use xsl substring-after, as shown:

    <xsl:value-of select="substring-after(@Real_x005F_x0020_Estate_x005F_x0020_Location,'#')"></xsl:value-of>

    Use this technique whenever you are working with lookup values in XSL transforms and need to get the human-friendly value.

    <end/>

    Technorati Tags: , ,
    December 20

    SharePoint Beagle December Issue Up & Live

    Many of you know this already, but the December edition of SharePoint Beagle is live.

    Every article is worth reading in my opinion.

    I want to give a little extra bump to my colleague's article (Natalya Voskrensenskya).  She provides a screen-shot extravaganza while describing how she used custom lists, workflow, SharePoint Designer, data views and other elements to implement a self-service training feature in MOSS.  She describes techniques that can be applied in many different business scenarios.  Check out her blog while you're at it.

    Don't forget to check out my article as well :)  I wrote about using MOSS to help an HR department manage open positions.

    </end>

    December 18

    MOSS Tells Me "Access Denied" to Edit a Workflow Task, But I Really Do Have Access

    I've implemented a workflow using SharePoint Designer in a site which is mainly read-only to "NT_AUTHORITY\Authenticated Users" (i.e. everyone).  There is a forms library for an InfoPath form.  There is an associated workflow tasks list as well so that when the workflow operates, it can assign tasks to people.

    I break permission for the forms library and task list so that any authenticated user can create forms and update their assigned tasks.

    I test with my low-privileges test account. 

    Can I fill out and save a form to the library? --> YES

    Can I access the task from an email link? --> YES

    Can I see an Edit workflow task link --> YES

    Can I click on that link?  --> NO ... Permission Denied.

    Why can I see an edit link that denies me permission when I click on it?  That's not how it's supposed to work...

    I go through the security configuration again, very closely.  I do it again.  I consider deleting this post because I obviously don't know anything about security.

    Finally, I search the Internets.  I find this highly unlikely MSDN forum thread:  http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1838253&SiteID=17

    The posters appear to be suggesting that the simple act of exporting the workflow to a drive platter will fix a MOSS security issue?  I can hardly believe I just typed that.  I'm reminded of the South Park episode about the 9/11 conspiracy where Stan is asking our Preznit, "Really?" over and over again. 

    So, nothing to lose, I fire up SPD, right-click on the workflow and save it to my c:\ drive.  That would be the c:\ drive on my laptop.  I'm looking over my shoulder the whole time so that no one will ask me, "why are you saving that workflow to your laptop?"

    Incredibly, that solves my problem.  I can edit the task.

    I hereby nominate this to be the Most Bizarre Workflow Workaround of 2007.

    </end>

    Technorati Tags:

    SharePoint Designer, Current Item's "Encoded Absolute URL" and HTTPS

    We often want to send an email that includes a hyperlink to the item or document that triggered the workflow.  We can use current item's "Encoded Absolute URL" for this purpose.  However, it always seems to use "http" for the URL protocol.  If your site runs on HTTPS then it will not work for you.

    image

    As far as I know, there is no out of the box solution to this problem.  If you need to use HTTPS, you have no out of the box option.

    To solve it, create a custom action that provides a string replace function to use in your workflow.  Alternatively, use a 3rd party tool such as the excellent package here: http://www.codeplex.com/spdwfextensions :)

    </end>

    Technorati Tags: ,
    December 17

    Quick and Easy: Determine Internal Column Name of a Site Column

    UPDATE: Jeremy Thake has blogged about this and put up some code for a console application that shows internal names.

    I was trying to get a content query web part to display a due date from a task and because the screen label is "Due Date", I assumed that the column name to use in <CommonViewFields> is "Due_x0020_Date".

    Wrong!

    The real column name in this case was "DueDate".

    How did I find it?  I re-read Heather Solomon's blog entry on modifying CQWP to show additional columns of data.  She describes this process at step #13.  Trust it.  It's correct.  At least, it was correct for me.  I did not trust it at first for another column with a much longer name.

    I say "Trust it" because I did not trust it and probably wasted near two hours butting my head up against a wall.  After I resolved the "DueDate" name, I wanted to add another field to <CommonViewFields>.  Using the Solomon technique, I was getting a column name like "XYZ_x0020_Project_x0020_Due_x00".

    I thought to myself, that's clearly a truncated name.  I went ahead and un-truncated it with no success.  I finally used the seemingly truncated name and it worked.

    Bonus tip: When I was working with the CQWP, if I added a bad internal name to <CommonViewFields>, the CQWP would tell me that the query had returned no results.  But, if I added a data type to the field name, it would return a result.  Adding the data type actually masked a problem since I was referencing a non-existent field.  I could add it, but when I tried to display its value, I would always get a blank. 

    This did not mask the error:

    <CommonViewFields>Due_x0020_Date;</CommonViewfields>

    This did mask the error:

    <CommonViewFields>Due_x0020_Date,DateTime;</CommonViewfields>

    </end>

    December 16

    Beware Breaking Changes to ItemStyle.xsl

    I was working with ItemStyle.xsl to customize the look of a Content Query Web Part and right about lunch time, I made a breaking change to the xsl.  I didn't realize it, but this had far reaching effects throughout the site collection.  I went off to lunch and upon my return, noticed this message appearing in a bunch of places:

    Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.

    I blamed the client (not realizing as yet that it was my fault at this point) but eventually noticed that visual studio intellisense was warning me that I had malformed XSL.  I corrected it and everything started working.

    Be darned careful when working with ItemStyle.xsl (and any of the global XSL files) -- breaking them affects many artifacts in the site collection.

    <end/>

    My Son Hacked Gamespot

    So, this morning, my son is determined to see an age-thirteen restricted Halo 3 video at Gamespot.  I'm outside shoveling snow, so I'm not there to help or hinder.  Necessity is the mother of invention and all that ... he  has a eureka! moment.  He realizes that even though Gamespot wants him to enter his real birth date, he can actually enter any birth date he wants.  Once he realized that, he made himself old enough to see the video.

    I'm not quite sure how I feel about this :)

    Sunday Funny: "It's Printing Garbage"

    At my first job out of college in 1991, I was lucky to to work for a manufacturing company with 13 locations, not including its corporate HQ in New Jersey.  I joined just when the company was rolling out a new ERP system.  We were a small IT department of about ten people altogether, two of whom Did Not Travel.  Part of the project involved replacing IBM System 36 boxes with HP hardware and HPUX.  Everyone used green tubes to access the system.

    The project rolls along and I'm sent down to Baltimore with a new co-worker, Jeff.  Our job was to power up the Unix box, make sure the O/S was running, install the ERP system, configure the ERP, train people on the ERP and do custom work for folks on the spot.  (This was a dream job, especially coming straight out of college).  Before we could really get off the ground, we needed to unpack all the green tubes, put them on desks and wire them.  And the best part was that we had to put the RJ11 connectors on ourselves.

    For some reason that I never understood and actually never thought to ask about at the time, we had had some contracting company come along and run cable throughout the plant, but we didn't have them put on the connectors.  So, there was a "patch box" with dozens of of unlabeled cables in the "computer room" and these snaked around the building to various places in the building.

    We worked our way through it over the course of a weekend, testing each wire, putting on a connector (making sure it was straight vs. crossed), ensuring the bit settings on the green tubes and printers were correct,  labeling wires, making sure that "getty" was running correctly for each port and probably a thousand other things that I've suppressed since then.  It all came together quite nicely.

    But, there was one important cable that we couldn't figure out.  The plant in Baltimore had a relationship with a warehousing location in New Jersey.  Some orders placed in Baltimore shipped out of that location.  There were two wires that we had to connect to the HPUX box: a green tube and a printer.  The green tube was easy, but the printer turned into a three-week nightmare.

    If you don't know it, or have suppressed it, dealing with green tubes and printers this way, there are various options that you deal with by setting various pins.  8-bit, 7-bit, parity (even/odd/none), probably others.  If you get one of those settings wrong, the tube or printer still shows stuff, but it will be total gibberish, or it will be gibberish with a lot of recognizable stuff in between.  Of course, these pins are hard to see and have to be set by using a small flat-edge screw driver.  And they are never standard.

    We set up the first of many quick calls with the NJ guy (a grizzled computer hater who probably curses us to this day).  We got the green tube working pretty quickly, but we couldn't get the printer to work.  It kept "printing garbage".  We would create a new RJ11 connector, switching between crossed and straight.  We would delete the port and re-created in Unix.  We went through the arduous task of having him explain to us the pin configuration on the printer, never really sure if he was doing it correctly.

    It's about time to go live, everything in Baltimore is humming, but we can't get the cursed printer up in NJ to work!  We've exhausted all possibilities except for driving back up to NJ to work on the printer in person.  To avoid all that driving, we finally ask him to fax us what he's getting when it's "garbage", hoping that maybe there will be some clue in that garbage that will tell us what we're doing wrong.

    When we got the fax, we immediately knew what was wrong.  See, our method of testing whether we had configured a printer correctly was to issue an "lp" command like this:

    lp /etc/passwd

    Basically, we printed out the unix password file.  It's always present and out of the box, always just one page.  You standard Unix password file looks something like this:

    smith:*:100:100:8A-74(office):/home/smith:/usr/bin/sh
    guest:*:200:0::/home/guest:/usr/bin/sh  

    We had been printing out the password file over and over again for several weeks and it was printing correctly.  However, to the end user, it was "printing garbage".

    </end>

    December 15

    Yet Another Network Credentials Multi-Challenge Issue and Solution

    My client recently installed a magic device from Juniper that apparently replaced their old Cisco network load balancer (NLB).  At about the same time, we installed a hotfix to address a workflow problem.

    A day or two later, we noticed a problem when we accessed the shared service provider (SSP).  We could get to it, but we would be challenged for a user ID and password many times on each page.  This didn't happen with the main portal app, nor central administration.  Naturally, we didn't know which of the two (Juniper or hotfix) would be the issue, though I strongly suspected the hotfix, figuring we had not installed it quite right.

    It turned out that Juniper had some kind of compression setting.  One of the robed figures over in the network group turned that setting off.  That solved our problem.

    This is not the first time that compression has been the root cause of a SharePoint problem for me.  IIS compression adversely affected a 3rd party tool from the good people at The Dot Net Factory for IE 6 browsers (IE 7 browsers worked without difficulty).

    So, add "compression" to the hazards list.

    </end>

    Credit to: http://www.elfwood.com/art/s/h/sherry/death_colour.jpg.html

    Technorati Tags: ,
    December 14

    Thinking About Changing Blogging Platform

    I started off my "blogging career" using Microsoft's platform and it's been good to me.  It's easy to post, there are good options and widgets for managing your "space", decent web storage and so forth.

    However, I really just fell into the MS solution with almost no planning.  That alone calls for me to evaluate where I am and where I'm going, in terms of a blogging platform.  There are also two important limitations that bother me right now vis-à-vis Windows Live Spaces. 

    First, I can't get very good statistics.  There are stats but the detail is often truncated and not presented in a way that allows for any kind of analysis.  There no sorting or export capability.  I get many blog ideas based on the kind of information people find (or especially fail to find) when they search my blog.  It's very hard to use lives spaces for that.

    Second, there does not seem to be any mechanism to "monetize" a windows live space blog.  In fact, in order to get rid of MS ads (from which I derive no benefit), I need to actually pay Microsoft.  (At least, that's how I understand it; I have been unable to get definitive answers to this and questions like it).

    Now that I've got an established pattern and set of blogging habits, I want to evaluate other options.  I've done some research and there are a lot of choices, but I'm curious as to what other people, particularly others in the SharePoint community (as bloggers or readers), like to use. 

    If this subject interests you and you have an opinion or are willing to share your experience, please leave a comment or email me directly.

    Thanks!

    <end/>

    Technorati Tags:
    December 13

    SharePoint Designer Email Sends ???? in an Email

    Forum users occasionally ask: Why does SharePoint Designer put ???? into my email instead of a field value?

    One reason this happens is because the variable to which you refer is null.

    This can happen because you are trying to reference a field from the "current item" but the user never entered a value into that form field.

    <end/>

    Technorati Tags:
    December 11

    Compare / Test for Blank Dates in SharePoint Designer Workflow

    Scenario: In a SharePoint Designer workflow, you need to determine if a date field is blank.  

    Problem: SPD does not provide a direct method for comparing dates to anything other than a date.  You cannot create a condition like this: "If [DateField] equals blank".

    Solution: Convert the date to a string.  Use string comparison to determine if the date is blank. 

    Screen Shots:

    The following screen shots show how to do this.  In this scenario, a field on an item, "Environmental Permits:First Permit Reminder Date", is submitted and the workflow fires in response.

    image

     

     image

    Notes:

    When I tried this, I was pleasantly surprised to learn that it works.  I was worried that SharePoint Designer might disallow the string assignment (Variable:StringReminderDateDate) but it did allow it.

    I was also concerned that allowing it, the value might be null and either blow up the WF at runtime or maybe raise the global temperature 1/2 a degree, but those concerns were unfounded.

    </end>

    Technorati Tags:
    December 10

    Bar is Still Pretty High to Extend MOSS

    Today, I was working with a client and describing how to modify the content query web part and display additional bits of information from a content type. 

    "First, you configure the CQWP to connect to its data sources, then you export it to your workstation, modify <CommonViewFields>, upload, remove the original and now it's 'primed' to display those other columns.  Next, open up SharePoint designer, navigate to the site collection root and locate ItemStyle.xsl.  Copy one of the templates as a useful starting point.  Go back and modify the CQWP to make use of this new template.  Finally, modify the template to render your new fields! (Don't forget to check it back in so that other users can see the results)."

    It's all quite clear to me (and most of us SharePoint developer types) what's going on and how it's quite nice, really, that the data retrieval aspects of the CQWP are so well-separate from the data presentation aspects.  But, it's not so easy to explain, is it?

    <end/>

    Technorati Tags: ,
    December 09

    Display Content Query Web Part Results in a Grid / Table

    Overview and Objective

    Out of the box, MOSS' Content Query Web Part (CQWP) displays its results in a list format, similar to search results.  It is also possible to display the results in a grid format (i.e. HTML table format).  Grid formats are better in some circumstances.  I describe how to achieve that effect in this article.

    Business Scenario

    I have worked with a client on an enterprise-wide MOSS rollout.  We have designed their taxonomy such that projects are first class citizens in the hierarchy and have their own top level site.  Project managers maintain a singleton list of project summary information, such as title, budget, expected completion date, remaining budget and other summary type fields.  By "singleton" I mean a custom SharePoint list guaranteed to contain only one item.   Simplistically, it looks like this:

    image

    The technical approach is much the same as described here (http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!447.entry).  The CQWP uses an XSL transform to emit HTML for the browser to render.

    I always envision the result before diving into the XSL because XSL is a nightmare.  Here's my desired result:

    image

    HTML like this generates that result:

     
    <html>
      <body>
        <center>
        <table border=1>
          
          <!-- Labels -->
          <tr bgcolor=blue>
            <td><font color=white><b>Project Name</b></font></td>
            <td align=right><font color=white><b>Complete Date</b></font></td>
            <td align=right><font color=white><b>Budget</b></font></td>
            <td align=right><font color=white><b>Actual Expense</b></font></td>
            <td><font color=white><b>Overall Status</b></font></td>
          </tr>
          
          <tr>
            <td>Re-wire computer room.</td>
            <td align=right>02/01/08</td>
            <td align=right>22,500.00</td>
            <td align=right>19,000.00</td>
            <td>In Progress</td>
          </tr>
            
          <tr>
            <td>Provision servers for SQL Upgrade</td>
            <td align=right>04/01/08</td>
            <td align=right>7,500.00</td>
            <td align=right>0.00</td>
            <td>Planned</td>
          </tr>
            
        </table>
        </center>
      </body>
    </html>

    Approach

    Follow these steps to create the grid:

    1. Identify the components of the grid (rows/columns).
    2. Define and create necessary site columns.
    3. Create sub sites for the projects and singleton lists.
    4. Add the CQWP to a web page and configure it to search for your lists.
    5. Modify the CQWP's XML to gather up the additional columns.
    6. Modify the XSL to generate a table.

    I'm going to concentrate on number six.  Numbers one through four are straight-forward and something that any CQWP user has already done.  Number five has been well-documented by others including this exhaustive screen-shot laden article from MSDN here (http://msdn2.microsoft.com/en-us/library/bb897399.aspx) and Heather Solomon's blog here (http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx).

    Nuts And Bolts

    Begin and implement steps one through five as per the MSDN documentation and Heather Solomon's article.

    At this point, you've added your CQWP to the page and you have your <CommonViewFields> configured as necessary.

    Following the usual steps, I get these intermediate results:

    1. Create a content type, a templatized custom list for that content type and two sites.  Here is the content type:

    image

    Here is the site structure:

    image

    2. Add the CQWP after creating my project subsites and singleton project summary lists:

    image

    3. Add all the additional information I want via the <CommonViewFields>:

            <property name="CommonViewFields" type="string">Project_x0020_Name;Project_x0020_Expenses;Project_x0020_Status;Project_x0020_Start_x0020_Date;Project_x0020_End_x0020_Date;Project_x0020_Budget</property>
    

    Note that I had to keep all the property fields on one line or it would not work (CQWP would tell me that the query returned no items).

    4. At this point, we're ready to move beyond the MSDN article and flip on over to Heather Solomon's article.  Follow her steps starting near step #5 to create a customized / unghosted version of ItemStyle.xsl.  I follow Heather's advice, up through step 11 and get these intermediate results:

    4.1: Name my XSL template as follows:

    <xsl:template name="Grid" match="Row[@Style='Grid']" mode="itemstyle">

    I also slightly modify her suggested <xsl:for-each ...> by adding a <br/> tag to provide a cleaner listing:

        <xsl:for-each select="@*">
          P:<xsl:value-of select="name()" /><br/>
        </xsl:for-each>
    

    4.2: I modify the web part, go to appearance and select my "Grid" style:

    image

    Apply the change and here is the result:

    image

    We can see from the above that the fields we want (Project name, expense, status, etc) are available for us to use when we emit the HTML.  Not only that, but we see the names by which we must reference those columns in the XSL.  For example, we reference Project Status as "Project_x005F_x0020_Name".

    At this point, we depart from Heather's blog and from the shoulders of these giants, I add my own little bit.

    ContentQueryMain.xsl

    NOTE: When making changes to both ContentQueryMain.xsl as well as ItemStyle.xsl, you need to check those files back in before you see the effect of your changes.

    For grid-making purposes, MOSS uses two different XSL files to produce the results we see from a CQWP.  To generate the previous bit of output, we modified ItemStyle.xsl.  MOSS actually uses another XSL file, ContentQueryMain.xsl to in conjunction with ItemStyle.xsl to generate its HTML.  As its name implies, ContentQueryMain.xsl is the "main" XSL that controls the overall flow of translation.  It iterates through all the found items and passes them one by one to templates in ItemStyle.xsl.  We'll modify ItemStyle.xsl to generate the open <table> tag before emitting the first row of data and the closing <table> tag after emitting the last row.  To accomplish this, ContentQueryMain.xsl is modified to pass two parameters to our "grid" template in ItemStyle.xsl, "last row" and "current row".  ItemStyle.xsl uses these to conditionally emit the necessary tags.

    Using Heather Solomon's technique, we locate ContentQueryMain.xsl.  It is located in the same place as ItemStyle.xsl.  This screen shot should help:

    image

    We need to make the following changes:

    • Modify an xsl template, "CallItemTemplate" that actually invokes our Grid template in ItemStyle.xsl.  We will pass two parameters to the Grid template so that it will have the data it needs to conditionally generate opening and closing <table> tags.
    • Modify another bit of ContentQueryMain.xsl that calls the "CallItemTemplate" to pass it a "LastRow" parameter so that LastRow may be passed on to our Grid template.

    Locate the template named "OuterTemplate.CallItemTemplate" identified by the string:

      <xsl:template name="OuterTemplate.CallItemTemplate">

    Replace the whole template as follows:

     
      <xsl:template name="OuterTemplate.CallItemTemplate">
        <xsl:param name="CurPosition" />
    
        <!-- 
          Add the "LastRow" parameter. 
          We only use it when the item style pass in is "Grid".
        -->
        <xsl:param name="LastRow" />
    
        <xsl:choose>
          <xsl:when test="@Style='NewsRollUpItem'">
            <xsl:apply-templates select="." mode="itemstyle">
              <xsl:with-param name="EditMode" select="$cbq_iseditmode" />
            </xsl:apply-templates>
          </xsl:when>
          <xsl:when test="@Style='NewsBigItem'">
            <xsl:apply-templates select="." mode="itemstyle">
              <xsl:with-param name="CurPos" select="$CurPosition" />
            </xsl:apply-templates>
          </xsl:when>
          <xsl:when test="@Style='NewsCategoryItem'">
            <xsl:apply-templates select="." mode="itemstyle">
              <xsl:with-param name="CurPos" select="$CurPosition" />
            </xsl:apply-templates>
          </xsl:when>
    
          <!-- 
                  Pass current position and lastrow to the Grid itemstyle.xsl template.
                  ItemStyle.xsl will use that to emit the open and closing <table> tags.
          -->
          <xsl:when test="@Style='Grid'">
            <xsl:apply-templates select="." mode="itemstyle">
              <xsl:with-param name="CurPos" select="$CurPosition" />
              <xsl:with-param name="Last" select="$LastRow" />
            </xsl:apply-templates>
          </xsl:when>
    
          <xsl:otherwise>
            <xsl:apply-templates select="." mode="itemstyle">
            </xsl:apply-templates>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>
    

    The comments describe the purpose of the changes.

    Of course, the "OuterTemplate.CallItemTemplate" is itself called from another template.  Locate that template by searching for this text string:

    <xsl:template name="OuterTemplate.Body">
    

    Scroll through the instructions in OuterTemplate.Body and insert the LastRow parameter as follows (shown as a comment in italics):

    <xsl:call-template name="OuterTemplate.CallItemTemplate">
      <xsl:with-param name="CurPosition" select="$CurPosition" />
      <!-- Insert the LastRow parameter. -->
      <xsl:with-param name="LastRow" select="$LastRow"/>
    </xsl:call-template>
    

    After all of this, we finally have things set up properly so that our ItemStyle.xsl can emit <table> tags at the right place.

    ItemStyle.Xsl

    NOTE: Again, check in ItemStyle.xsl after making any changes so that you see the effect of those changes.

    We have two tasks here:

    • Replace the entire Grid template.  You can copy/paste from below.
    • Add some mumbo jumbo outside the template definition that enables "formatcurrency" template to work.  (You can tell that I have a tenuous handle on XSL).

    First, near the top of ItemStyle.xsl, add this line:

      <!-- Some mumbo jumbo that enables us to display U.S. currency. -->
      <xsl:decimal-format name="staff" digit="D" />
    
      <xsl:template name="Default" match="*" mode="itemstyle">
    

    Note that I added it directly before the <xsl:template name="Default" ...> definition.

    Next, go back to our Grid template.  Replace the entire Grid template with the code below.  It is thoroughly commented, but don't hesitate to email me or leave comments on my blog if you have questions.

     
      <xsl:template name="Grid" match="Row[@Style='Grid']" mode="itemstyle">
    
        <!-- 
          ContentMain.xsl passes CurPos and Last.
          We use these to conditionally emit the open and closing <table> tags.
        -->
        <xsl:param name="CurPos" />
        <xsl:param name="Last" />
    
        <!-- The following variables are unmodified from the standard ItemStyle.xsl -->
        <xsl:variable name="SafeImageUrl">
          <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
            <xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="SafeLinkUrl">
          <xsl:call-template name="OuterTemplate.GetSafeLink">
            <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="DisplayTitle">
          <xsl:call-template name="OuterTemplate.GetTitle">
            <xsl:with-param name="Title" select="@Title"/>
            <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="LinkTarget">
          <xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
        </xsl:variable>
    
        <!--
          Here we define a variable, "tableStart".  This contains the HTML
          that we use to define the opening of the table as well as the column
          labels.  Note that if CurPos = 1, it includes the HTML in a CDATA tag.
          Otherwise, it will be empty.
          
          The value of tableStart is emited every time ItemStyle is called via 
          ContentQueryMain.xsl.
        -->
        <xsl:variable name="tableStart">
          <xsl:if test="$CurPos = 1">
            <![CDATA[ 
            <table border=1>
              <tr bgcolor="blue">
                <td><font color="white"><b>Project Name</b></font></td>
                <td align="right"><font color="white"><b>Complete Date</b></font></td>
                <td align="right"><font color="white"><b>Budget</b></font></td>
                <td align="right"><font color="white"><b>Actual Expense</b></font></td>
                <td><font color="white"><b>Overall Status</b></font></td>
              </tr>   
            ]]>
          </xsl:if>
        </xsl:variable>
    
        <!-- 
          Another variable, tableEnd simply defines the closing table tag.
          
          As with tableStart, it's always emited.  This is why its value is 
          assigned conditionally based upon whether we've been passed the last
          row by ContentQueryMain.xsl.
        -->
        <xsl:variable name="tableEnd">
          <xsl:if test="$CurPos = $Last">
            <![CDATA[ </table> ]]>
          </xsl:if>
        </xsl:variable>
    
        <!-- 
          Always emit the contents of tableStart.  If this is not the first
          row passed to us by ContentQueryMain.xsl, then we know its value
          will be blank.
          
          Disable output escaping because when tableStart it not blank, it
          includes actual HTML that we want to be rendered by the browser.  If
          we don't tell the XSL parser to disable output escaping, it will generate
          stuff like "&lt;table&gt;" instead of "<table>".
        -->
        <xsl:value-of select="$tableStart" disable-output-escaping="yes"/>
    
    
        <tr>
          <!--
          P:Project_x005F_x0020_Name
          P:Project_x005F_x0020_End_x005F_x0020_Date
          P:Project_x005F_x0020_Budget
          P:Project_x005F_x0020_Expenses
          P:Project_x005F_x0020_Status
          -->
          <td>
            <xsl:value-of select="@Project_x005F_x0020_Name"/>
          </td>
    
          <td align="right">
            <xsl:value-of select="@Project_x005F_x0020_End_x005F_x0020_Date"/>
          </td>
    
          <td align="right">
            <xsl:call-template name="formatcurrency">
              <xsl:with-param name="value" 
    select="@Project_x005F_x0020_Budget"></xsl:with-param> </xsl:call-template> </td> <td align="right"> <xsl:call-template name="formatcurrency"> <xsl:with-param name="value" select="@Project_x005F_x0020_Expenses">
    </xsl:with-param> </xsl:call-template> </td> <td> <xsl:value-of select="@Project_x005F_x0020_Status"/> </td> <!-- All of the following is commented out to clarify things. However, bring it back and stuff it into a <td> to see its effect. --> <!-- <div id="linkitem" class="item"> <xsl:if test="string-length($SafeImageUrl) != 0"> <div class="image-area-left"> <a href="{$SafeLinkUrl}" target="{$LinkTarget}"> <img class="image-fixed-width" src="{$SafeImageUrl}"
    alt="{@ImageUrlAltText}"/> </a> </div> </xsl:if> <div class="link-item"> <xsl:call-template
    name="OuterTemplate.CallPresenceStatusIconTemplate"/> <a href="{$SafeLinkUrl}"
    target="{$LinkTarget}" title="{@LinkToolTip}"> <xsl:value-of select="$DisplayTitle"/> </a> <div class="description"> <xsl:value-of select="@Description" /> </div> </div> </div>
    --> </tr> <!-- Emit the closing table tag. If we are not on the last row, this will be blank. --> <xsl:value-of select="$tableEnd" disable-output-escaping="yes"/> </xsl:template> <xsl:template name="formatcurrency"> <xsl:param name="value" select="0" /> <xsl:value-of select='format-number($value, "$DDD,DDD,DDD.DD", "staff")' /> </xsl:template>

     

    Results

    Putting all of that together, I get the following result:

    image 

    Concluding Thoughts

    Naturally, now that you have grid-making support in place, you can use other templates to display dates and currency as per your requirements.  You can also put in conditional formatting, such as displaying projects who have exceeded their budget in red. 

    You should leverage existing MOSS CSS styles so that the results conform to your site's branding.

    It feels like a lot of work to do this, but it really is not.  First time through, expect to spend the better part of a day getting it perfect.  I find there's a "zen" to the process and once you've gone through it a few times (as well as working through graphing and search results) it all starts to jell.

    Keep in mind that ItemStyle.xsl and ContentQueryMain.xsl need to be checked in for you see the results of your changes. 

    Don't get hung up on the specific facts of the business scenario.  This approach does not depend upon singleton lists or anything like that.  Modify the approach to generate a table for any results provided by the content query web part.

    <end/>

    Subscribe to my blog!

    December 08

    Standard WSS/MOSS Data Entry Screens Do Not Support Cascading Drop-downs (or other intra-from communication)

     

    UPDATE (04/2008): This great blog entry shows a good javascript based approach to this problem: http://webborg.blogspot.com/2008/04/add-functions-and-events-to-sharepoint.html

    UPDATE II: (04/2008): This blog entry looks promising as well: http://www.cleverworkarounds.com/2008/03/13/free-mosswss-2007-web-part-hide-controls-via-javascript/

    Several times a week, if not daily, forum users describe a requirement that would normally be met via cascading drop-downs.  For example, I have two drop-down controls:

    • List of U.S. states
    • List of U.S. cities.

    As responsible UI providers, we want it to operate like this:

    • Paul selects a U.S. state from the drop-down. 
    • This causes the cities drop-down to filter only those cities that belong to the selected state. 
    • Paul selects a city from this filtered list.

    There is no out-of-the-box support for this feature.  In fact, there is no OOB support for any kind of direct intra-form communication.  This includes programmatically hiding/enabling/disabling fields in response to field changes elsewhere on the form.

    The real objective of this article to to describe possible solutions and these are the options as I know them:

    1. Develop a custom column type.  As a custom-column-developer, you have full control over the "world" of that custom column.  You can implement a cascading drop-down that way. 
    2. Consider using workflow.  In some cases, you want to automatically assign a value to field based on another field's value.  In this case, you would normally try to use a calculated column, but some times, it just won't get the job done.  SharePoint Designer workflow is a relatively administer-friendly alternative to dropping down into code and visual studio.  If you go this route, be aware of the issue addressed by this article (http://paulgalvin.spaces.live.com/blog/cns!CC1EDB3DAA9B8AA!405.entry).
    3. Event handlers: Like workflow, this is an after-the-fact solution.  Your event handler is a .NET assembly (C#, VB.NET) to which SharePoint passes control.  The object you develop has access to the data of the list (and the whole object model) and can do any needed calculation.
    4. Use SharePoint Designer to create custom entry forms.  I don't have direct experience with this approach, but I hear they are doing good things with NewForm.aspx these days :)
    5. Roll your own ASP.NET data entry function (as a stand-alone web page or as a web part) and use that instead.

    If anyone knows other and/or better options, please post a comment and I'll update the body of this post.

    <end/>

    Technorati Tags:

    December 05

    Yes/No (check box) filtering in Content Query Web Part

    To filter for a query for the Yes/No check box entitled "PG Milestone", configure CQWP like this:

    image

    This is another one of those obvious-once-you-know-it but hard-to-find-an-answer-to questions: How to filter on a Yes/No check box using the content query web part.

    The first search result I find using the search term "filter yes/no content query web part" is flat out wrong, so I thought I'd put this up there and see if it can replace the incorrect result in typical search results.

    It's quite easy: True values = "1" and false values do not equal "1" (pretty retro, actually).

    In the above example, I created site column of type "Yes/No (checkbox)" named "PG Milestone".  I added it to a doc library, uploaded a few documents, set the value for a couple and tested it.

     

    <end/>