Category Archives: CAML

CrossListQueryInfo not able to return MultiLookup Fields

Some time ago I wrote a blogpost about how to use the CrossListQueryInfo and CrossListQueryCache to be able to find any item within a site within a very small amount of time. Hower, since today I know that this method cant be used when you are trying to retrieve items that contain a MultiLookupField in the ViewFields.

I came accross this limitation when I accidentally changed a LookupField into a MultiLookupField. Suddenly, my webpart that made use of the CLQI didn’t return any items anymore, although I was sure that I didn’t modify any code. For some reason I immediately had to think about the Database diagram that i created some time ago and I opened the database to check something.

Although all ListItems with its data are stored into the AllUserData table, there is some data that is stored somewhere else: the AllUserDataJunctions. This table stores the multilookup data. This might be the reason that the CLQI isn’t able to display the multilookup results.

Anybody has any thoughts on this?

SharePoint – Retrieving login name from SPUserField in a list

For a long time I didnt know how to retrieve a login name from a SPUser field in a SharePoint List. When a user doesn’t have a userProfile, he is stored in the SPUser field as <number>;#<Domain\loginName>, and when he does have a profile, his name is stored as <number>;#<name of user>. That number doesn’t represent the ID in the User Profile Provider, so it wasn’t possible to use that ID to retrieve the login name (or other user information).

Today, I accidentally came accros an option that allowed me to retrieve all the “standard” user information:

ID, name of user, loginname, email and some other extra information.

When making a new SPQuery, do the following:

query.ExpandUserField = true;

this option enables the access op extra user information possible. Why didn’t I know this before, stupid me ;)?