0

I have one choice field setup as radio buttons in custom list . Values of choice field are New/Approved/Rejected . My custom list is as follows. I want to display the results based on choice new , approved or rejected

enter image description here

I had tried with the following url but it does not work dont display any results I have status web property also based on that i want to display the results from custom list

function applyFilter() {

    var selectedFilter = decodeURIComponent(getQueryStringParameter("Status"));

    var requestUri = appweburl + "/_api/SP.AppContextSite(@target)/web/Lists/getByTitle('myListName')/fields?$Filter=Status  eq '" + selectedFilter  + "'&@target='" + hostweburl + "'";

    getResults(requestUri);
}

function getResults(requestUri) {

   var executor = new SP.RequestExecutor(appweburl.toLowerCase());

    // execute AJAX request
    executor.executeAsync({
        url: requestUri,
        method: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: renderList,
        error: errorHandler
    });
}

I tried alot but didn't get what's the problem.

  • Why you are taking Status from getQueryStringParameter? Why not from radio button. Can you confirm getQueryStringParameter("Status") is giving you some value before applying filter? – Atish Dipongkor - MVP Jan 19 '16 at 9:29
  • yes iam getting from queryStringParameter , As i said i have set the property "Status" in webpart • Status – limits the suggestions to show by the given status. If set to Approved it will only show approved, to New only New etc. If set blank, it should should show all but Rejected. – meer Jan 19 '16 at 14:33
0

If you want to get results (i.e. items), then your REST query is slightly wrong - instead of /fields? you should use /items? , like this:

var requestUri = appweburl + "/_api/SP.AppContextSite(@target)/web/Lists/getByTitle('myListName')/items?$Filter=Status  eq '" + selectedFilter  + "'&@target='" + hostweburl + "'";
  • thank u i already updated. – meer Jan 20 '16 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.