SPServices icon indicating copy to clipboard operation
SPServices copied to clipboard

CAML query hides rich text fields?

Open Palumbob opened this issue 6 years ago • 6 comments

When i console log my data from getting list data from a list without a query, all fields show up. When i add a query to my call, it hides any rich text fields i have?

HELP

Palumbob avatar May 17 '18 22:05 Palumbob

Can you post the different calls you're making? What you're describing doesn't really make sense.

sympmarc avatar May 17 '18 22:05 sympmarc

var projectsList = $().SPServices.SPGetListItemsJson({ listName: "Input for Success Stories", debug: false });

When i use this call above, without the query, i get all the list items without issue and all the fields in the list.

When i use this call above, with the query, i get the list item i want (ID = 4), but the rich text fields do not show up.

I use spservices all the time, this is throwing me for a loop.

Palumbob avatar May 17 '18 23:05 Palumbob

It's hard for me to know what to tell you without seeing the query you're sending. The call above will retrieve all items in the list using the default view for the list. You would only be be seeing all the columns if you have all of them displayed in the default view. (I recommend using ViewFields, as someone - most likely you! - could change the default view and you'd start getting different results.) Your query could be changing what is retrieved somehow.

sympmarc avatar May 18 '18 00:05 sympmarc

query = CAMLQuery: "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Number'>4</Value></Eq></Where></Query>", my caml query is correct, i am only returning the one list item. but its odd because the response strips out the rich text fields.

I tested the same call on the out of the box announcement list and it works as it should, it doesn't hide the body column (rich text). but it hides my rich text fields in my custom list?!?!?

as i stated, i use (and LOVE) spservices so this one oddity is confusing me!

so to be clear, when i use the above query, i get the data ( im console logging the response), but in my array, im missing all rich text fields. (this is for a custom list).

works fine on the announcements

Palumbob avatar May 18 '18 00:05 Palumbob

I remember having similar issue in the past. This is really a "Why Sharepoint" and less about SPServices. As Marc indicated, when you define a query, Sharepoint will not use the default list view to gather up what fields should be returned (because the query is essentially an override to the default view). It does return some, but I personally was never able to actually identify any pattern as to which are returned (ex. ID and Title seem to always return)

You will be best served by ALWAYS defining in your request specifically which field you want.

Also: remember - even if you request a field be returned, if a row does not have any data for that field, then that row will also "appear" as if the field value was not returned. You will not get something like ows_Body="" - so make sure you account for that as well.

Paul

-- sent from mobile

purtuga avatar May 18 '18 00:05 purtuga

So are the Rich Text column values being return empty or not being returned at all? If it's the latter, I'd suggested adding something like:

CAMLViewFields: "<ViewFields><FieldRef Name='MyRichTextColumn' /></ViewFields>",

to your call. As @purtuga and I have mentioned, it's always best to use ViewFields to request the columns you want, anyway.

sympmarc avatar May 18 '18 03:05 sympmarc