Forum Discussion

Americo Perez's avatar
Americo Perez
Iron Contributor
Mar 28, 2019

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

Resources