Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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"))

share|improve this question
add comment

2 Answers 2

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.

share|improve this answer
    
Good point. Easy to test the theory by spitting out the list definition and looking at the XML. –  Charles Chen Dec 22 '10 at 21:19
add comment

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.

share|improve this answer
    
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 Dec 28 '10 at 12:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.