Forum Discussion
Americo Perez
Mar 26, 2019Iron Contributor
Get user name using List view component?
Hi, I am trying to get the user name (display name) from a people column in a spfx web part using the List view component but I am getting undefined. The column calls SalesManager (internal name) ...
- Mar 26, 2019
Americo Perez Can you share what your select value is? Person field is complex field type, that you need to select the properties and expand on the field.
.select('SalesManager/FirstName, SalesManager/LastName').expand('SalesManager')
Americo Perez
Mar 27, 2019Iron Contributor
Tahanks Beau Cameron , right now I am selecting everything:
public async getAgreements(): Promise<Agreement[]> {
let select = '*';
let Agreements: Agreement[] = [];
const items = await sp.web.lists.getById('823e0102-5928-4f8a-bcda-f1794bd9026b').items.select(select).get();
items.forEach(item => {
Agreements.push({
Title: item.Title,
AgreementName: item.Title,
CustomerAgreementNr: item.CustomerAgreementNr,
AgreementType: item.AgreementType,
SalesManager: item.SalesManagerId,
ContactPerson: item.ContactPerson,
DeliveryType: item.DeliveryType,
AgreementStartDate: item.AgreementStartDate,
AgreementEndDate: item.AgreementEndDate,
AgreementEnded: item.AgreementEnded,
LastPriceAdjustment: item.LastPriceAdjustment,
NextPriceAdjustment: item.NextPriceAdjustment,
});
});
return new Promise<Agreement[]>(async(resolve) => {
resolve(Agreements);
});
}
Regards!
Beau Cameron
Mar 27, 2019MVP
Americo Perez I can see that, but that is not how the REST call works. It's a complex field type that you need to expand on to get it's values.