How to retrieve the Page ID of newly created page in site pages library using javascript
I am creating the page programmatically under site pages library and want to get the ID of that newly created page.
January 22nd, 2015 9:01am
Hi,
you can apply this to the page and let me know if it worked
Free Windows Admin Tool Kit Click here and download it now
January 22nd, 2015 2:55pm
Hi,
The following JavaScript Code for your reference:
<script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"> </script> <script type="text/javascript"> $(document).ready(function () { var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Site Pages')/items?$select=ID&$orderby=Created desc&$top=1"; // execute AJAX request $.ajax({ url: requestUri, type: "GET", headers: { "ACCEPT": "application/json;odata=verbose" }, success: function (data) { alert("The newly created page ID is " + data.d.results[0].ID); }, error: function () { alert("Failed to get customer"); } }); }); </script>
Best Regards
February 3rd, 2015 3:40am