Incomplete encoding of FieldRef names

Dec 18, 2007 at 8:04 PM
Hi it's me again. Sorry to be littering your discussion board with bugs, but I didn't think it appropriate for me to try to add things to what looks to be your internal issue tracker. Anyways...

This bug is pretty simple. Basically in your CamlFactory class line 163 or so, you XmlConvert.EncodeName on the field name to get the internal representation for Sharepoint. This works fine except when you start using special characters like the colon. Colons are default in column names for BDC field types. For instance take the field User: Name. This will encode to User:x0020LanID but SharePoint internally sees the FieldRef as Userx003a_x0020_LanID.

If you point Reflector at Microsoft.SharePoint.Utilities and look at the SPStringUtility class and inspect EncodeNonAlphaNumericalAsciiChars and IsBadSymbol you'll see the WSS algorithm for encoding FieldRefs.

I hacked this code into CamlFactory and was able to get things working again for BDC fields.

fieldName.Value = EncodeNonAlphaNumericalAsciiChars(XmlConvert.EncodeName(field));
Dec 18, 2007 at 11:27 PM
I ran into the same exact issue today with mapped BDC fields. Good catch.

I hope this fix makes it into the next build.
Feb 7, 2008 at 6:49 AM
Thanks for the feedback and sorry for the delay it took to answer. I'll take a look at this issue in the next go-round; since the goal is to avoid any static dependency on Microsoft.SharePoint.dll, algorithms like this will have to get their own private implementation in our core DLL. This is something I'm looking at actively.