Getting “ows_MetaInfo” Nicely with SPServices

I know that I’m going to look for this tip again, so this post is as much as a “note to self” as anything else, though I expect that others will use it, too.

One of the streams I watch with HootSuite is a plain old search for “SPServices”. It’s useful for me to see what people are saying about SPServices (this one and not that one) and I occasionally retweet the good stuff.

I spotted a great tip from Steve Ottenad (@sottenad) yesterday about displaying the MetaInfo from list items nicely. It’s so simple, yet as far as I know, undocumented.!/sottenad/status/86135314728501248

Simply add Properties="True" to your CAMLViewFields, like so:

CAMLViewFields: "<ViewFields Properties='True' />",

Thanks, Steve!


Bug in SharePoint’s Lists Web Service with GetListItems?

I was trying to track down some odd behavior in SharePoint’s Lists Web Service tonight, and I think I’ve found what I can only call a bug. 

Here’s the scenario.  All of these conditions must apply:: 

  • Using the GetListItems operation
  • Querying a list which has a required multi-select column
  • Specifying columns to return in the ViewFields parameter (whether or not the multi-select column above is specified)
  • The multi-select column has more than one value selected in an item (or items)

In this specific case, there are multiple copies of each item returned, one per value which is set in the required multi-select column.

I found two other posts on the Interwebs about this.  In both cases, the writer found the same problem, but was unable to determine the reason or a fix:

Both posts are from 2008, so I’m sure these guys have long since moved on, though I did leave Andy a comment.

It looks like a fix which will work is to not specify the columns in ViewFields.  This will make the GetListItems calls less efficient, of course, but it will make them work correctly.

The other solution, which doesn’t really make any sense, is to include

CAMLQueryOptions: "<QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>",

Setting IncludeMandatoryColumns to FALSE doesn’t do what it it is supposed to do per the SDK, but in this case it serves a useful purpose by eliminating the duplicate items. I worry when I find these seemingly kludgy fixes, but it is *extremely* unlikely that the Web Services are going to change, so I use them anyway.  Even if IncludeMandatoryColumns suddenly started doing what it should, I’d be fine here (and the calls to GetListItems would be even *more* efficient.)

Any other ideas out there?

Here’s an example.  There’s only one item in the States list for Massachusetts.  There’s a column called Staff, which is a Person or Group, allows multiple selections, and is required:


In my call to GetListItems, I’m specifying the two columns I would like returned:

CAMLViewFields: "<ViewFields><FieldRef Name='" + opt.relationshipListParentColumn + "' /><FieldRef Name='" + opt.relationshipListChildColumn + "' /></ViewFields>",

GetListItems returns a copy of the item per value for Staff. Note that the Staff column is being returned, even though i am *not* requesting it. (I’m only requesting the Region and State [Title] columns, but the other columns besides Staff come back regardless. Not exactly what I asked for, but it seems to be intentional in all of my experience with GetListItems. They are sort of the “base” columns which you’d need to do anything useful with the items.)