How can I dynamically get the ID of the current discussion thread in javascript?
Currently, I have the following code:
function submitReply() {
var ctx = new SP.ClientContext.get_current();
var discussionItem = ctx.CurrentItem;
var body = CKEDITOR.instances['commentArea'].getData();
var messageProperties = {'Body': body};
createMessage(discussionItem,messageProperties,
function(){
console.log('Reply has been post successfully');
},
function(sender,args){
console.log('Error occurred while posting a reply:' + args.get_message());
}
);
}
When I use ctx.CurrentItem the return value is null.
Here is the link to my complete code: https://pastebin.com/jNFbUBaB
var ctx = new SP.ClientContext.get_current();
is not need.SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() { submitReply(); });