Last active
January 3, 2016 18:29
-
-
Save vgrem/8502403 to your computer and use it in GitHub Desktop.
Create Discussion Item in Discussions List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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