I had written the code to insert the values in sharepoint list,And I was unable to to perform the operation.When I check step by step using "alert" then I see error as "[Object Object]" . Below is my written JSOM Script,Can any one help me in knowing why I am facing the error and what's wrong in my below code

alert('start script');
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', addlistitems);

function addlistitems()

alert('in Add Function');
var clientContext = new SP.ClientContext.get_current();

var myList = clientContext.get_web().get_lists().getByTitle('PRF');

  • alert can only show Strings.. quickly learn to use console.log (or .info or .error) statements. Apr 17, 2016 at 18:28

1 Answer 1


Try this code from MSDN: https://msdn.microsoft.com/en-us/library/office/jj163201.aspx

function createListItem(siteUrl) {
    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('Announcements');

    var itemCreateInfo = new SP.ListItemCreationInformation();
    this.oListItem = oList.addItem(itemCreateInfo);
    oListItem.set_item('Title', 'My New Item!');
    oListItem.set_item('Body', 'Hello World!');

        Function.createDelegate(this, this.onQuerySucceeded), 
        Function.createDelegate(this, this.onQueryFailed)

function onQuerySucceeded() {
    alert('Item created: ' + oListItem.get_id());

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.