Any way to return only the VewFields

Jan 22, 2015 at 2:59 PM
Is there a way to define ViewFields and have them returned as a string?
I'm experimenting with this library and the use of SOAP operations (SP2007)... I would like to get back the string of ViewFields... but looks like the only way is to define .View().. but that returns back a <View> along with it.

I guess I could eval the string in JQuery and then select the ViewFields element only... but was trying to avoid that...

Jan 22, 2015 at 3:13 PM
You're right, currently it's not possible to have ViewFields alone, only within a View.

But actually I think separate ViewFields tag generation might be handy when using camljs with SPServices. I'll see if I can squeeze some time and implement this one. Thanks for the good idea!
Jan 22, 2015 at 3:29 PM
Anyone else who might find this thread looking for the same thing - here is my current workaround:
                CAMLViewFields  : (function(){
                    var reEx = (/\<ViewFields\>.*\<\/ViewFields\>/i).exec(
                            new CamlBuilder().View(["Tile", "Expires", "When"]).ToString()
                    if (reEx) {
                        return reEx[0];
                    return "<ViewFields></ViewFields>"
Jan 23, 2015 at 4:37 PM
Hi Andrew.
I was trying to find the updated version that you posted about yesterday on twitter, but the version here on codeplex still shows a date of Oct... where can I download it from?
Also, what's the method name to be used? ViewFields()?
Jan 27, 2015 at 8:00 AM
Hi Paul,
For some reason I received the notification about this post only today. Probably Codeplex was having some problems again.

I have updated the library with the new changes everywhere exactly as I mentioned on twitter, including here, Nuget, and even camljs-console in WebStore.
I decided not to create a separate release, because this change is a very small one. Codeplex displays only release date on the first page, but if you go into Downloads tab, you will notice "Updated" date and also each file has the date as well.

So please feel free to download fresh version of the library.

Usage is very simple:
  var viewFields = new CamlBuilder().ViewFields("Title", "AssignedTo", "Author").ToString();
This produces the expected:
    <FieldRef Name="Title" />
    <FieldRef Name="AssignedTo" />
    <FieldRef Name="Author" />
Screenshot from camljs-console:
camljs console screenshot: ViewFields element
Jan 27, 2015 at 11:41 AM
Yeah, same here. Suddenly got a flood of emails.
Thanks for the email. I'm going to update my project to includ it.

Paul T.

-- Sent from Mobile