BACKGROUND: Using SharePoint 2013, calling a REST Ajax call in javascript. When successful, this returns results in a data set, which I put in a variable called data.
My OData syntax uses $expand on a SharePoint Person {the datatype}
field, such that I can return the person's name, as well as their ID.
So, in the call.done function(data, status, jqXHR)
, if the field being "expanded" is called "Employee", then the data results can be accessed by using a for loop and step through the returned data using:
for (var i=0; i<data.d.results.length i++) {
var id data.d.results[i].Employee.Id
var emp data.d.results[i].Employee.Title
}
DESIRE: I'd like to dynamically pass a field name, such that I can do something like:
var emp = data.d.results[i].[pField].Title
PROBLEM: This Bracket Notation, nor any variation, works.
QUESTION:
Is it possible to dynamically reference this object name, returned by the $Expand [object]
, and if so, what is the proper format?
Thanks,
Steve Clark - Easy Bins Dumpster Rentals | http://www.easy-bins.com