How to get Current List Item in SharePoint 2013/Office 365 using JavaScript?
In this blog, I will give you the piece of code to access the current SharePoint list item using JavaScript. Below is the piece of code to achieve the same.
function getCurrentListItem(success, error) {
var context = SP.ClientContext.get_current();
var web = context.get_web();
var currentList = web.get_lists().getById(_spPageContextInfo.pageListId);
var currentListItem = currentList.getItemById(_spPageContextInfo.pageItemId);
context.load(currentListItem);
context.executeQueryAsync(
function () {
var currentEmpItem= currentListItem.get_item(‘Employee_x0020_Name’);
if (currentItem!= null) {
alert(“Your employee name is “,+currentEmpItem);
}
error
);
Do check out the below articles on
Set the Search Centre URL in SharePoint 2013 Using Javascript
Get-the-list-of-user-profiles-in-office-365
How to set the Client People Picker value in SharePoint 2013.
Retrieving Query Results by Date Range in SharePoint Site 2013 Using REST SEARCH API
Share you SharePoint Site to External User in SharePoint Online /Office 365
Differences between Search features in SharePoint 2010 vs 2013/Office 365
Happy SharePointing Folks!! Hope it helps you guys!!