0

i am trying to set item on the list(announcement) of share point but it happened to be like i am able to only set item that is like 'Title' , 'body' so how would i set the item(customized) on the list. i am attaching the code with it please help..!

    try {
        var clientContext = new SP.ClientContext.get_current();
        var appContextSite = new SP.AppContextSite(clientContext, hostweburl);
        var oWebsite = appContextSite.get_web();
        /*this.field = this.bList.get_fields().addFieldAsXml(
        '<Field DisplayName=\'Template Manifest Id\' Type=\'Number\' />', 
        true, 
        SP.AddFieldOptions.defaultValue
        );
        this.field.update();
        this.field = this.bList.get_fields().addFieldAsXml(
        '<Field DisplayName=\'Template Url\' Type=\'Text\' />', 
        true, 
        SP.AddFieldOptions.defaultValue
        );
        this.field.update();*/
        for(var i = 0; i< this.lst.length; i++){    
            console.log(" "+i);
            var itemCreateInfo = new SP.ListItemCreationInformation();
            this.listItem = this.bList.addItem(itemCreateInfo);
            this.listItem.set_item('Title',this.lst[i]);
            this.listItem.set_item('Template Manifest Id',105);
            this.listItem.set_item('Template Url',' ');
            this.listItem.update();
            clientContext.load(this.listItem);
            //console.log(this.listItem.get_id());
        }
        clientContext.executeQueryAsync(
        Function.createDelegate(this, this.success),
        Function.createDelegate(this, this.error)
        );
        console.log("List made..!");//return false;
        }
    catch(e) {alert(e.get_message());}

this code give me an error:

errorColumn 'Template Manifest Id' does not exist. It may have been deleted by another user." at line this.listItem.set_item('Template Manifest Id',105);

1 Answer 1

0

Make sure you are using field internal name not the display name. You can get the field internal name by right click on the field name (on the list setting page) and copy the value of the field= in the URL

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.