2

I have two sites on the same collection. There is a people picker field on my list in site2. I am in Sharepoint 2010.

mysharepointsite/site1
mysharepointsite/site2

I am using the Sharepoint REST API to get list data from site2 (calling from site1). All other fields except my people picker are being returned. I also tried this with the asmx web services via the SPServices library, same result. Is this by design, maybe a limitation related to passing people picker data between two sites? I have some workarounds, but this is just bugging me now.

$.ajax({
    url: stageGateBaseURL + "listdata.svc/Investment",
    type: "GET",
    dataType: "json",
    success: function(response){
        debugger
        $.each(response.d.results, function(key, value) {  

             var projectManager = value.ProjectManager; //people picker is not returned in the results.

        });
    },
    error: function(response){
        debugger
    }
});
3

In order to retrieve User field details, $expand OData query option needs to be applied to query.

For example, the following query returns Title along with projected* Name property of CreatedBy user field from Pages library:

http://intranet.contoso.com/_vti_bin/listdata.svc/Pages?$select=Title,CreatedBy/Name&$expand=CreatedBy

Projected fields are retrieved by joining lists, in this case Pages and User Information lists

Example

var svcUrl = 'http://intranet.contoso.com/_vti_bin/listdata.svc/';
$.ajax({
    url: svcUrl + "Pages?$select=Title,CreatedBy/Name&$expand=CreatedBy",
    type: "GET",
    dataType: "json",
    success: function(response){
        console.log(response.d.results[0].CreatedBy.Name); //print CreatedBy Name 
    },
    error: function(response){
        console(JSON.stringify(response));
    }
});

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.