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

SharePoint 2013 Field value from SharePoint list through JQuery and Rest coming undefined

$
0
0

I am trying to get field values  (field1 and field2)from the SharePoint list JQuery and Rest services to auto populate two other txt fields, but while the Title field is coming fine the other two field values are coming undefined.  The below is the part of the code pulling the value:

function setFields(txtValue) {

        var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('ListName')/items?$filter=Title eq '" + txtValue + "'";

   alert(requestUri);              
                              
        // execute AJAX request
        $.ajax({
            url: requestUri,
            type: "GET",
            headers: { "ACCEPT": "application/json;odata=verbose" },
            success: function (data) {
                var dataResults = data.d.results;
                alert(dataResults[0].Title);
                var firstField = dataResults[0].field1;
                 alert(firstField);
                var secField = dataResults[0].field2;
                                                               
              },
            error: function () {
                alert("Failed to get details");
            }
        });
}

It seems the array value in var dataResults need to be changed. How to find the array value for field1 and field2 so that my variables firstField and secField can be populated? At present, they show undefined while Title is showing correct value.

Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>