Skip to main content
added 24 characters in body
Source Link
Eric Alexander
  • 43.4k
  • 10
  • 54
  • 93

Using the rest api to retrieve information about my documents. The documents use managed metadata which isn't expanded correctly when using the stand REST api. So I found this fix which uses REST with a CAML query. That has been working very well up to now. The CAML query I use is

        var caml = "<View Scope='RecursiveAll'>" +
                      "<Query><Where><And>" +
                          "<BeginsWith>" +
                            "<FieldRef Name='FileRef' />"+
                            "<Value Type='URL'>"+filterStr+"</Value>" +
                          "</Begins>" +
                          "<Neq>" +
                            "<FieldRef Name='_ModerationStatus' />" +
                            "<Value Type='Number'>"+this.APPROVAL_STATUS.rejected.val+"</Value>" +
                          "</Neq>" +
                      "</And></Where>" +
                          "<OrderBy>" +
                            "<FieldRef Name='FLSequence' Ascending='TRUE' />" +
                          "</OrderBy>" +
                      "</Query>" +
                    "</View>"

This retrieves all kinds of information about my document, ID, Title, custom columns, properly expanded metadata columns. But the one thing it doesn't return is the name of the file!

In my searching the main problem people seem to be working on is how to filter by file name in a CAML query which doesn't help me much. I did try adding ViewFields in there:

 
<ViewFields>
     <FieldRef Name='LinkFilename' />
     <FieldRef Name='FileLeafRef' />
     <FieldRef Name='Name' />
   </ViewFields>

But none of those pulled back the file name AND it also stopped returning all the other good info.

In this situation how would I go about retrieving the name of a document? Is there some kind of wildcard select all fields for a CAML query? Am I just SOL?

Using the rest api to retrieve information about my documents. The documents use managed metadata which isn't expanded correctly when using the stand REST api. So I found this fix which uses REST with a CAML query. That has been working very well up to now. The CAML query I use is

        var caml = "<View Scope='RecursiveAll'>" +
                      "<Query><Where><And>" +
                          "<BeginsWith>" +
                            "<FieldRef Name='FileRef' />"+
                            "<Value Type='URL'>"+filterStr+"</Value>" +
                          "</Begins>" +
                          "<Neq>" +
                            "<FieldRef Name='_ModerationStatus' />" +
                            "<Value Type='Number'>"+this.APPROVAL_STATUS.rejected.val+"</Value>" +
                          "</Neq>" +
                      "</And></Where>" +
                          "<OrderBy>" +
                            "<FieldRef Name='FLSequence' Ascending='TRUE' />" +
                          "</OrderBy>" +
                      "</Query>" +
                    "</View>"

This retrieves all kinds of information about my document, ID, Title, custom columns, properly expanded metadata columns. But the one thing it doesn't return is the name of the file!

In my searching the main problem people seem to be working on is how to filter by file name in a CAML query which doesn't help me much. I did try adding ViewFields in there:

 

But none of those pulled back the file name AND it also stopped returning all the other good info.

In this situation how would I go about retrieving the name of a document? Is there some kind of wildcard select all fields for a CAML query? Am I just SOL?

Using the rest api to retrieve information about my documents. The documents use managed metadata which isn't expanded correctly when using the stand REST api. So I found this fix which uses REST with a CAML query. That has been working very well up to now. The CAML query I use is

        var caml = "<View Scope='RecursiveAll'>" +
                      "<Query><Where><And>" +
                          "<BeginsWith>" +
                            "<FieldRef Name='FileRef' />"+
                            "<Value Type='URL'>"+filterStr+"</Value>" +
                          "</Begins>" +
                          "<Neq>" +
                            "<FieldRef Name='_ModerationStatus' />" +
                            "<Value Type='Number'>"+this.APPROVAL_STATUS.rejected.val+"</Value>" +
                          "</Neq>" +
                      "</And></Where>" +
                          "<OrderBy>" +
                            "<FieldRef Name='FLSequence' Ascending='TRUE' />" +
                          "</OrderBy>" +
                      "</Query>" +
                    "</View>"

This retrieves all kinds of information about my document, ID, Title, custom columns, properly expanded metadata columns. But the one thing it doesn't return is the name of the file!

In my searching the main problem people seem to be working on is how to filter by file name in a CAML query which doesn't help me much. I did try adding ViewFields in there:

<ViewFields>
     <FieldRef Name='LinkFilename' />
     <FieldRef Name='FileLeafRef' />
     <FieldRef Name='Name' />
   </ViewFields>

But none of those pulled back the file name AND it also stopped returning all the other good info.

In this situation how would I go about retrieving the name of a document? Is there some kind of wildcard select all fields for a CAML query? Am I just SOL?

Source Link
Rothrock
  • 1.6k
  • 8
  • 52
  • 101

Can't get filename of document with REST api/CAML query

Using the rest api to retrieve information about my documents. The documents use managed metadata which isn't expanded correctly when using the stand REST api. So I found this fix which uses REST with a CAML query. That has been working very well up to now. The CAML query I use is

        var caml = "<View Scope='RecursiveAll'>" +
                      "<Query><Where><And>" +
                          "<BeginsWith>" +
                            "<FieldRef Name='FileRef' />"+
                            "<Value Type='URL'>"+filterStr+"</Value>" +
                          "</Begins>" +
                          "<Neq>" +
                            "<FieldRef Name='_ModerationStatus' />" +
                            "<Value Type='Number'>"+this.APPROVAL_STATUS.rejected.val+"</Value>" +
                          "</Neq>" +
                      "</And></Where>" +
                          "<OrderBy>" +
                            "<FieldRef Name='FLSequence' Ascending='TRUE' />" +
                          "</OrderBy>" +
                      "</Query>" +
                    "</View>"

This retrieves all kinds of information about my document, ID, Title, custom columns, properly expanded metadata columns. But the one thing it doesn't return is the name of the file!

In my searching the main problem people seem to be working on is how to filter by file name in a CAML query which doesn't help me much. I did try adding ViewFields in there:

But none of those pulled back the file name AND it also stopped returning all the other good info.

In this situation how would I go about retrieving the name of a document? Is there some kind of wildcard select all fields for a CAML query? Am I just SOL?