Created
January 19, 2014 21:16
-
-
Save vgrem/8511140 to your computer and use it in GitHub Desktop.
Get all Messages from Discussions List via SharePoint CSOM
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 getMessages(listTitle,disscussionId,OnItemsLoaded,OnError) | |
{ | |
var context = new SP.ClientContext.get_current(); | |
var web = context.get_web(); | |
var list = web.get_lists().getByTitle(listTitle); | |
context.load(list); | |
var qry = createAllMessagesByDisscussionIDQuery(disscussionId); | |
var messageItems = list.getItems(qry); | |
context.load(messageItems); | |
context.executeQueryAsync( | |
function() { | |
OnItemsLoaded(messageItems); | |
}, | |
OnError | |
); | |
} | |
function createAllMessagesByDisscussionIDQuery(disscussionId) { | |
var qry = new SP.CamlQuery; | |
var viewXml = "<View Scope='Recursive'> \ | |
<Query> \ | |
<Where> \ | |
<Eq> \ | |
<FieldRef Name='ParentFolderId' /> \ | |
<Value Type='Integer'>" + disscussionId + "</Value> \ | |
</Eq> \ | |
</Where> \ | |
</Query> \ | |
</View>"; | |
qry.set_viewXml(viewXml); | |
return qry; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment