2

I have used angularjs to query for data through listData.svc. A json response is returned. May someone suggest how to get the value of a specific field with javascript?

3

Here is an example:

function(data) {
    $.each(data.d.results, function(i,result) {
    //get item property
    var fieldValue= result[FieldName];
    });
| improve this answer | |
2

It's not clear to me exactly what you are asking so I will give a broad set of answers.

  1. All field names are based on their display titles, not the Internal Name.

  2. If you only want the value of specific fields to be returned you use $select= followed by the field names. The following example will return only the values of the fields I specify in the query string and the item's __metadata which is always returned with a query.

../_vti_bin/ListData.svc/MyList?$select=Title,Destription,Created,CreatedBy

  3.  Complex fields such as lookups (including users whose values are lookups to items in the UserInformationList) need to be specified in the query string using $expand= For example if I am looking at a task list with a field called "Assigned to" I would specify my URL as follows:

../_vti_bin/ListData.svc/MyTaskList?$select=Title,Destription,Created,CreatedBy,StartDate,DueDate,AssignedTo&$expand=CreatedBy,AssignedTo

This would give me a full object graph of the CreatedBy (internal name Author) and AssignedTo fields. Fields that are shown in dropdowns or radio/check boxes in the standard SP UI generally have their values encoded in their object's Value field. Using the example of a task list again I would look for the item's priority in the PriorityValue field or if I chose to expand the object it would be in Priority.Value.

| improve this answer | |

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.