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

Do I have to put a prefix of ows before retrieving fields? because I am trying to obtain additional fields and not being able to?

 soapEnv += "<listName>My SP List</listName>";
    soapEnv += "<query><Query><OrderBy Override='TRUE'><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query></query>";
    soapEnv += "<viewFields><ViewFields><FieldRef Name='Title'/><FieldRef Name='MyDescription'/><FieldRef Name='MyURL'/><FieldRef Name='ows_FileLeafRef'/></ViewFields></viewFields><rowLimit></rowLimit>";
    soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>";
share|improve this question

3 Answers 3

up vote 2 down vote accepted

As mentioned in the other answers, you need the StaticName or Internal Name (Microsoft uses both terms in different places) rather than the DisplayName when you specify column names in your Web Services calls.

The other important point is that what you get back is preceded by "ows_". So if you ask for "Title", what you get back in the XML is "ows_Title".

share|improve this answer
    
Long time no see... I did use both with or without ows_ but not being successful. –  Robert G May 27 '11 at 21:44
    
Okay in the soap I am using internal name and in the java I am using with the prefix and now seems to be resolving. However, myLink gives me this abc.com,%20abc%20news%20link instead of just the link. –  Robert G May 27 '11 at 21:47
    
@SPEveryone: myLink was a hyperlink type field in SP. I deleted this and added a single line text field. Now it's all working. –  Robert G May 27 '11 at 21:54
    
Yes, hyperlink columns store both the text and the URL, which is what you want, really. You simply parse them apart to get whichever piece you need. –  Marc D Anderson May 28 '11 at 3:56
    
Thanks! And why some fields doesn't return at all? For example 'ContentTypeId' adds additional field to z:row, but '_HasCopyDestinations' doesn't. –  surlac Dec 14 '12 at 9:48

You do not need the ows_, but you do need to use the internal name, which is not necessarily the same as the display name. To determine the internal name go to the List Settings page for your list and click on the columns you are interested in. Look at the url in the address bar and find the Field parameter in the query string. It may be something like My_x0020_Field.

share|improve this answer
    
My fields are simple and I am using internal name. For example, NewsLink is NewsLink and so forth. I am getting undefined. –  Robert G May 27 '11 at 21:41
    
soapEnv += "<listName>My List</listName>"; soapEnv += "<query><Query><OrderBy Override='TRUE'><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query></query>"; soapEnv += "<viewFields><ViewFields><FieldRef Name='Title'/><FieldRef Name='ows_FileLeafRef'/><FieldRef Name='NewsLink'/><FieldRef Name='Description'/></ViewFields></viewFields><rowLimit></rowLimit>"; soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>"; –  Robert G May 27 '11 at 21:43

Each FieldRef within ViewFields corresponds to a field to be returned in the query.

Here's a code sample - It will return the Title, Active, Description, and MyLink fields where the Title field equals "Title Value":

SPQuery query = new SPQuery();
query.ViewFields = @"<FieldRef Name='Title'/><FieldRef Name='Active'/><FieldRef Name='Description'/><FieldRef Name='MyLink'/>";
query.Query = 
@"
<Where>
    <Eq>
        <FieldRef Name='Title'/>
        <Value Type='Text'>Title Value</Value>
    </Eq>
</Where>";

SPList list = SPContext.Current.Web.Lists.TryGetList("My SP List");
SPListItemCollection items = list.GetItems(query);

I see you've changed your original question

I think you may have some formatting issues with your XML. See this question for some additional help.

share|improve this answer
    
excellent. however, this is in java using soap envelope. –  Robert G May 27 '11 at 21:04
    
Ok, I was unsure based on the limited results. To answer your original question, yes, each <FieldRef> within <ViewFields> corresponds to each column that is returned. –  Tim Gabrhel May 27 '11 at 21:06
    
@It seems I cant get hold off myLink aka myURL and descriptin field –  Robert G May 27 '11 at 21:16

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.