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.
1 Answer
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 -
-
hey @deeksha , did you try this? If its working, could you please mark it as answer ? Its just a checkmark besides the answer Commented Jan 22, 2018 at 12:25
-
In export interface ISPList{person or group column will be of string type only}? Commented Jan 22, 2018 at 12:30
-
yes, please see the JSON values and then create your interface accordingly Commented Jan 22, 2018 at 12:35
-
I am still getting error for my person or group column, under that column value it is showing [object Object] Commented Jan 23, 2018 at 5:17