Pages

Showing posts with label SCOM. Show all posts
Showing posts with label SCOM. Show all posts

Thursday, October 30, 2014

Create list item using SharePoint Client Object Model (also get the ID of newly created Item)

function createNewItem(){
         var clientContext = SP.ClientContext.get_current();
         var oList = clientContext.get_web().get_lists().getByTitle(List_Name);  
         var itemCreateInfo = new SP.ListItemCreationInformation();
         this.oListItem = oList.addItem(itemCreateInfo);

         oListItem.set_item('Group', group_value);
         oListItem.update();
         clientContext.load(oListItem);
         clientContext.executeQueryAsync(
                  Function.createDelegate(this, this.onQuerySucceed), 
                  Function.createDelegate(this, this.onQueryFailed));
} // createNewItem method ends.

function onQuerySucceed() {
        var newID =  oListItem.get_id();
}

function  onQueryFailed(){
        alert(‘operation failed’);
}