SPFx Get label name from managed metadata column?

Iron Contributor



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:


Term Store.png


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
NexPriceAdjustment,SalesManager/FirstName, SalesManager/LastName')

items.forEach(item => {
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,


2 Replies
best response confirmed by Americo Perez (Iron Contributor)

Hi @Americo Perez 


@Marc Anderson 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! 


Hope this helps

Thanks @Joel Rodrigues it helped!

It wasn't that hard!