Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to get discussion topics which has Best Replies using REST API?

$
0
0

Hi,

As per this https://social.technet.microsoft.com/Forums/lync/en-US/b08b2495-c26a-45d4-b399-17eba40f29c6/best-response-id-info-discussion-board?forum=sharepointgeneral

If a discussion topic gets a best reply then the ID of the best reply is stored in Best Response ID Column. So I am trying the following to get the ONLY Topics of a user which has best Replies, but gives me error.

var url = siteURL + "/_api/web/lists/getbytitle('"+listname+"')/Items?$select=Title,Author/Title,Author/EMail,Author/FirstName,Author/LastName&$expand=Author/Id&$filter=(ContentType eq 'Discussion') and (Author/Id eq 10) and (Best_0x0020_Response_0x0020_Id gt 0)

$.ajax({
  url: url,
  method: "GET",
  async: false,
  headers: { "Accept": "application/json; odata=verbose" },
  success: function (data) {
            if(data.d.results.length<1){
                alert("No items");
                history.go(-1);
            }
            else{
                 var Title = "";
                 var BestResponseId = "";
                 for (var i = 0; i < data.d.results.length; i++) {              
     Title = Title + data.d.results[i].Best_0x0020_Response_0x0020_Id+ ".\n";
       }
       alert("Many items\n" + Title );

        $.each(data.d.results, function(key, val) {
               console.log(val.Best_0x0020_Response_0x0020_Id);
           });
               
           }

        },
  error: function (data) { 
            alert("error"); 
  }
 });

If I write a loop to see all column names of this Discussion list, I could see best Response Id column.



Viewing all articles
Browse latest Browse all 7589

Trending Articles