Trying to use GetListItems to search document library using a file name

Dec 8, 2015 at 1:20 PM
Edited Dec 8, 2015 at 1:37 PM
I'm trying to build a dashboard showing information about documents actively involved in a workflow. I have a working query against the Tasks list to find active tasks, but the only link I have back to the associated document library is in the WorkflowLink field. Because I want to also list custom columns from the document library, I'm parsing what I get from WorkflowLink and trying to use that to query the document library. I first tried a query using the LinkFilename column, but was getting a "permission denied" error. I found this article which indicated that you could not use this field, but that you could use FileLeafRef. I've tried that, but am still getting "permission denied". What column can you use in querying a document library if all you have is the file name? I'm using SPServices 2014.02 with jQuery 1.11.3, and here is the code snippet:
qryFields = "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Document_x0020_ID' /></ViewFields>";
qryText = "<Query><Where><Contains><FieldRef Name='FileLeafRef' /><Value Type='Text'>" + docName + "</Value></Contains></Where></Query>";
console.log(qryText);
$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "EIS Documents",
    CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='Recursive' /><OptimizeFor>FolderUrls</OptimizeFor></QueryOptions>",
    CAMLViewFields: qryFields,
    CAMLQuery: qryText,
    completefunc: function (xData2, Status2) {
        console.log(xData2.responseXML);
        var itemCount2 = $(xData2.responseXML).SPFilterNode("rs:data").attr("ItemCount");
        console.log("itemCount2="+itemCount2);
        if (itemCount2 = 1) {
            $(xData2.responseXML).SPFilterNode("z:row").each(function() {
                docTitle = $(this).attr("ows_Title");
                docID = $(this).attr("ows_Document_x0020_ID");
            });
        }
    }
});
Thanks in advance.
Dec 8, 2015 at 1:47 PM
Update ... I found a typo which I've corrected and I'm now getting the information from the document library using FileLeafRef.
Coordinator
Dec 8, 2015 at 8:18 PM
Glad you figured it out on your own!

M.