I'm trying to write a query using the JSOM to get the last document uploaded to a document library by the current user. The reason I'm doing this is because I have an upload button on a form and need to have a way to get a reference to the document after it's uploaded and display a link to it on the page. So I have this code and it's failing with an "unable to complete this request - undefined" error:
//query for the last uploaded item by this user var clientContext = new SP.ClientContext('example.com'); var oList = clientContext.get_web().get_lists().getByTitle('List Title'); var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml('<View><RowLimit>1</RowLimit><Query><Where><Eq><FieldRef Name="Editor" /><Value Type="User">domain\\user</Value></Eq></Where><OrderBy><FieldRef Name="Modified" Ascending="False"></OrderBy></Query></View>'); this.collListItem = oList.getItems(camlQuery); clientContext.load(collListItem, 'Include(Id, Name)'); clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
Am I going about this the right way? Amy I using CAML syntax incorrectly? I'm really new to SharePoint and unsure if this is even the proper way to get a reference to this document. I'm having the user upload it by using the Upload.aspx form in a modal dialog and haven't found a way to just return the document from the modal.