Skip to content

Instantly share code, notes, and snippets.

@vgrem

vgrem/createDiscussion.js

Last active Jan 3, 2016
Embed
What would you like to do?
Create Discussion Item in Discussions List
function createDiscussion(listTitle,properties,OnItemAdded,OnItemError)
{
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle(listTitle);
context.load(list);
var discussionItem = SP.Utilities.Utility.createNewDiscussion(context, list, properties.Subject);
for(var propName in properties) {
if(propName == 'Subject') continue;
discussionItem.set_item(propName, properties[propName])
}
discussionItem.update();
context.load(discussionItem);
context.executeQueryAsync(
function() {
OnItemAdded(discussionItem);
},
OnItemError
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.