{"id":322,"date":"2014-01-11T02:06:25","date_gmt":"2014-01-10T20:06:25","guid":{"rendered":"http:\/\/markwheeler.com\/wordpress\/?p=322"},"modified":"2014-01-11T02:06:25","modified_gmt":"2014-01-10T20:06:25","slug":"jquery-sharepoint-document-library-for-most-recent-files","status":"publish","type":"post","link":"https:\/\/www.markwheeler.com\/?p=322","title":{"rendered":"JQuery Sharepoint Document Library for most Recent File(s)."},"content":{"rendered":"<p>I have an email-enabled document library where reports in PDF format are delivered daily.<br \/>\nI need to display the most recent reports embedded on a Web Part page.<br \/>\nThe filenames are structured as name_datestamptimestamp.pdf<br \/>\nDifferent reports are sent here so I have to discern a part of the filename (eg. LAN Utilization, WAN Utilization)<\/p>\n<div id=\"SPDF\">\n<pre>&lt;script type=\"text\/javascript\" src=\"\/jquery-1.8.3.min.js\"&gt;&lt;\/script&gt;&lt;script type=\"text\/javascript\"&gt;\/\/ &lt;![CDATA[\n\/\/alert(\"So Far So Good\");\n$(document).ready(function() {\n\/\/ alert(\"Document is Ready\");\n var soapEnv =\n \"&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;  &lt;soap:Envelope xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\" xmlns:soap=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\"&gt;  \n&lt;soap:Body&gt;  \n&lt;GetListItems xmlns=\"http:\/\/schemas.microsoft.com\/sharepoint\/soap\/\"&gt;  \n &lt;listName&gt;CMReports&lt;\/listName&gt;  \n&lt;viewFields&gt;  \n&lt;ViewFields&gt; \n &lt;FieldRef Name='LinkFilenameNoMenu' \/&gt; \n &lt;\/ViewFields&gt; \n &lt;\/viewFields&gt; \n &lt;query&gt; \n &lt;Query&gt; \n &lt;Where&gt; \n &lt;Contains&gt; \n &lt;FieldRef Name='FileLeafRef' \/&gt; \n &lt;Value Type='File'&gt;PARTOFFILENAME&lt;\/Value&gt; \n &lt;\/Contains&gt; \n &lt;\/Where&gt; \n &lt;OrderBy&gt; \n &lt;FieldRef Name='Modified' Ascending='FALSE' \/&gt; \n &lt;\/OrderBy&gt; \n &lt;\/Query&gt; \n &lt;\/query&gt; \n &lt;rowLimit&gt;1&lt;\/rowLimit&gt; \n &lt;\/GetListItems&gt; \n &lt;\/soap:Body&gt; \n &lt;\/soap:Envelope&gt;\";\n\/\/ alert(soapEnv);\n$.ajax({\n url: \"\/_vti_bin\/lists.asmx\",\n type: \"POST\",\n dataType: \"xml\",\n data: soapEnv,\n complete: processResult,\n contentType: \"text\/xml; charset=\"utf-8\"\"\n });\n});\n function processResult(xData, Status) \n { \n \/\/ alert(xData.responseXML.xml);\n $(xData.responseXML).find(\"z\\:row\").each(function() {\n \/\/ alert($(this).attr(\"ows_LinkFilenameNoMenu\"));\n var ObjHTML = \"&lt;embed width='940' height='1024' src='SUBSITE\/DOCUMENTLIBRARY\" + $(this).attr(\"ows_LinkFilenameNoMenu\") + \"#navpanes=0' type='application\/pdf'&gt;&lt;\/embed&gt;\";\n \/\/ $(\"#PDF\").append(xData.responseXML.xml);\n \/\/ alert(ObjHTML);\n $(\"#SPDF\").append(ObjHTML);\n });\n }\n\/\/ ]]&gt;&lt;\/script&gt;\n&lt;div id=\"SPDF\" \/&gt;<\/pre>\n<\/div>\n<p>I saved this snippet in an HTML file and call it from a Content Editor Web Part elsewhere.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2,10,11],"tags":[62,99],"class_list":["post-322","post","type-post","status-publish","format-standard","hentry","category-computer","category-sharepoint","category-software","tag-jquery","tag-sharepoint-2010"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322"}],"version-history":[{"count":0,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/322\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}