Posts

Showing posts with the label ECMAScript list Access

SharePoint: Accessing List Items using ECMAScript

Image
Here is a simple, slim down with no frills attached code to access list item using ECMAscript in SharePoint 2010/13 . You can simply use this code in Content Editor Webpart and trigger this function using a HTML button or something and display the results in a HTML. Here I am trying to access all items under all the fields of the list. In the onSuccess function which executed in case the list items are accessed successfully, I further call another method that will make use of the function GetListItems() { try { setNewEventLinkURL(); objContext = new SP.ClientContext.get_current(); objWeb = objContext.get_web(); objList = objWeb.get_lists().getByTitle("My List"); objContext.load(objList); objContext.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFail)); } catch (e) { } } function onSuccess(sender, args) { var TextFiled = ""; //var ListEnumerator =...