Forum Discussion
SPFx Get label name from managed metadata column?
Hi,
I am trying to get the label of a managed metadata column from a web part but I a number instead of the name of the metadata (see image below) :
My term storage looks like this:
As you see in my query I get a number instead of "Customer1, Customer2..."
This is my code:
const items = await sp.web.lists.getByTitle('Avtal Demo').items
.select('Title,CustomerAgreementNr,AgreementType,ContactPerson,DeliveryType,
AgreementStartDate,AgreementEndDate,AgreementEnded,Customer,LastPriceAdjustment,
NexPriceAdjustment,SalesManager/FirstName, SalesManager/LastName')
.expand('SalesManager')
.get();
items.forEach(item => {
Agreements.push({
AgreementName: item.Title,
CustomerAgreementNr: item.CustomerAgreementNr,
AgreementType: item.AgreementType,
ContactPerson: item.ContactPerson,
DeliveryType: item.DeliveryType,
AgreementStartDate: item.AgreementStartDate,
AgreementEndDate: item.AgreementEndDate,
AgreementEnded: item.AgreementEnded,
LastPriceAdjustment: item.LastPriceAdjustment,
NextPriceAdjustment: item.NexPriceAdjustment,
Customer: item.Customer,
SalesManager: item.SalesManager.FirstName + ' ' + item.SalesManager.LastName,
});
});
Do I need to do something special to get the correct name for the Customer?
Best regards,
Americo
MarcDAnderson has a great blog post where he shared a JavaScript function to deal with this issue. I use it all the time and it simply works!
https://sympmarc.com/2017/06/19/retrieving-multiple-sharepoint-managed-metadata-columns-via-rest/
Hope this helps
MarcDAnderson has a great blog post where he shared a JavaScript function to deal with this issue. I use it all the time and it simply works!
https://sympmarc.com/2017/06/19/retrieving-multiple-sharepoint-managed-metadata-columns-via-rest/
Hope this helps
- Americo PerezIron Contributor