various shenanigans.

JQuery Sharepoint Document Library for most Recent File(s).

I have an email-enabled document library where reports in PDF format are delivered daily.
I need to display the most recent reports embedded on a Web Part page.
The filenames are structured as name_datestamptimestamp.pdf
Different reports are sent here so I have to discern a part of the filename (eg. LAN Utilization, WAN Utilization)

<script type="text/javascript" src="/jquery-1.8.3.min.js"></script><script type="text/javascript">// <![CDATA[
//alert("So Far So Good");
$(document).ready(function() {
// alert("Document is Ready");
 var soapEnv =
 "<?xml version="1.0" encoding="utf-8"?>  <soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">  
<GetListItems xmlns="">  
 <FieldRef Name='LinkFilenameNoMenu' /> 
 <FieldRef Name='FileLeafRef' /> 
 <Value Type='File'>PARTOFFILENAME</Value> 
 <FieldRef Name='Modified' Ascending='FALSE' /> 
// alert(soapEnv);
 url: "/_vti_bin/lists.asmx",
 type: "POST",
 dataType: "xml",
 data: soapEnv,
 complete: processResult,
 contentType: "text/xml; charset="utf-8""
 function processResult(xData, Status) 
 // alert(xData.responseXML.xml);
 $(xData.responseXML).find("z\:row").each(function() {
 // alert($(this).attr("ows_LinkFilenameNoMenu"));
 var ObjHTML = "<embed width='940' height='1024' src='SUBSITE/DOCUMENTLIBRARY" + $(this).attr("ows_LinkFilenameNoMenu") + "#navpanes=0' type='application/pdf'></embed>";
 // $("#PDF").append(xData.responseXML.xml);
 // alert(ObjHTML);
// ]]></script>
<div id="SPDF" />

I saved this snippet in an HTML file and call it from a Content Editor Web Part elsewhere.

Close Bitnami banner