1

Truncated column question.

I am consuming a Sharepoint list via Lists.asmx API.

All is well with the exception of one column, which I can't reference by name.

The column was initially named in such a way that Sharepoint is both escaping/encoding it AND truncating it.

The problem is, I cannot figure out how to reference it by name, because the name is truncated RIGHT IN THE MIDDLE of the 'x0020'

Via the Sharepoint site URL, the name is: Weekly%5fx0020%5fUpdates%5fx002d%5f%5fx002

My assumption is that would translate to: ows_Weekly_x0020_Updates-__x002

?

Suggestions? Renaming/Recreating the column is not an option, I need to access it.

Ways I have tried to access it...

FieldRef Name='Weekly_x0020_Updates_x002d__x002'

if (ds.Tables[1].Columns.Contains("ows_Weekly Updates-__x002"))

2 Answers 2

1

Are you sure your code is correct?

It looks like instead of:

if (ds.Tables[1].Columns.Contains("ows_Weekly Updates-__x002"))

You need:

if(ds.Tables[1].Columns.Contains("ows_Weekly_x0020_Updates_x002d__x002"))

In my experience, the truncated column name is the internal column name.

1
  • Good point. Easy to test the theory by spitting out the list definition and looking at the XML. Commented Dec 22, 2010 at 21:19
0

Have you considered trying to "denormalize" it?

If you have the content type, you can just loop through the content type fields or if you are just using list fields, just loop through the list fields and match the field names using string comparison find the SPField and then getting the full name from there.

Also, as you are using a DataSet, consider examining the column names on the DS in the debugger or write them to the trace output so you know the format that the DS is expecting.

1
  • To follow up, it turns out that the ReadXml method on the DataSet object was dropping certain fields from the XML schema completely. I used Fiddler and the debugger to verify this behavior and abandoned trying to use the DataSet in favor of just reading the attributes in the XML. Thanks again for your insight.
    – rodnex
    Commented Dec 28, 2010 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.