Monday, November 25, 2013

Creating list using Java Script Client Object Model in SharePoint 2010

var oList;

 function createList()
    var clientContext = new SP.ClientContext('/');
    var oWebsite = clientContext.get_web();

   var listCreationInfo = new SP.ListCreationInformation();
   listCreationInfo.set_title('My Announcements List');

   this.oList = oWebsite.get_lists().add(listCreationInfo);

  clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

 function onQuerySucceeded()
        var result = oList.get_title() + ' created.';

 function onQueryFailed(sender, args)
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

No comments:

Post a Comment

SharePoint Deployment Error : The specified path, file name, or both are too long.

Hi, Sometimes we get surprised with below error while deploying wsp file... Solution : To overcome with this issue, we just ne...