magritton
12/8/2016 - 2:27 AM

Javascript add SharePoint list item. The success here has no actions.

Javascript add SharePoint list item. The success here has no actions.

function addAttributeItem(listTitle,itemFieldName,itemValue) {
    var clientContext = new SP.ClientContext.get_current();
    var list = clientContext.get_web().get_lists().getByTitle(listTitle);
    var itemCreateInfo = new SP.ListItemCreationInformation();
    this.oListItem = list.addItem(itemCreateInfo);
    oListItem.set_item(itemFieldName, itemValue);
    oListItem.update();
    clientContext.load(oListItem);
    clientContext.executeQueryAsync(
    	function(){
    		//item insert complete
    	},
    	function(a,b){
    		alert('Request failed. ' + b.get_message() + '\n' + b.get_stackTrace());
    	}
    );
}