0

I have make one web part in spfx, I am able to fetch values of all columns of sharepoint list except one which is of type person or group, In this column there are multiple names I want to fetch all names of that particular column, how can I do this? In my webpart under that column it is showing UNDEFINED.

0

You need to use $expand to get additional details from the People field.

Assuming that you need details of Author field, modify your endpoint as below:

`${this.context.pageContext.web.absoluteUrl}/_api/lists/GetByTitle('Test')/items?
$select=Title,ID,Author/Title,Author/Department,Author/EMail&$expand=Author`;

So, in your method it will be used as :

var endPointUrl = `${this.context.pageContext.web.absoluteUrl}/_api/lists/GetByTitle('Test')/items?$select=Title,ID,Author/Title,Author/Department,Author/EMail&$expand=Author`;

this.context.spHttpClient.get(endPointUrl,SPHttpClient.configurations.v1)  
      .then((response: SPHttpClientResponse) => {  
        response.json().then((responseJSON: any) => {  
          console.log(responseJSON);  
        });  
      });  

Reference -

Get details from Person or Group fields

4
  • hey @deeksha , did you try this? If its working, could you please mark it as answer ? Its just a checkmark besides the answer – Gautam Sheth Jan 22 '18 at 12:25
  • In export interface ISPList{person or group column will be of string type only}? – Deeksha Gupta Jan 22 '18 at 12:30
  • yes, please see the JSON values and then create your interface accordingly – Gautam Sheth Jan 22 '18 at 12:35
  • I am still getting error for my person or group column, under that column value it is showing [object Object] – Deeksha Gupta Jan 23 '18 at 5:17

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.