get List/Library item id using QueryString

Here is the code snippet to get the SharePoint list or library item id using the Query String

<script language="javascript" type="text/javascript">
$(document).ready(function(){
   //alert('onLoad');
   var itemID= getItemId()
   //alert(itemID);
 

});

function getItemId()
{
regex = new RegExp("[\\?&]"+"ID"+"=([^&#]*)");
qs = regex.exec(window.location.href);
//alert(qs[1]);
var recordId=qs[1]

return recordId;

}


Comments

Popular posts from this blog

Clearing the Configuration Cache for SharePoint

SharePoint 2013 REST API CRUD Operations

Add List Item Attachments to Task Form using Nintex Workflow and Forms