I've a list in SPFx with a column type of Managed metadata. Now I'll add an item in that list with a web part. But how can I do this?

import { TaxonomyPicker, IPickerTerm } from "@pnp/spfx-controls-react/lib/TaxonomyPicker";

public async addNew(product: Product): Promise<void> {
    const resp = await this
            Title: product.title,
            Category: product.category ? {
                TermGuid: product.category.key,
                Label: product.category.name
            } : null


product.category is type of IPickerTerm comming from TaxonomyPicker of my React component.

Code above doesn't throw an error but when I selected the added item again, the category is empty.

<d:Category m:type="SP.Taxonomy.TaxonomyFieldValue">
    <d:WssId m:type="Edm.Int32">0</d:WssId>

Do I miss anything here?


I must send this with __metadata inside Category and with a WssId:

let toSend: any = {
    Title: product.title,
    Category: product.category ? {
        __metadata: {
            type: 'SP.Taxonomy.TaxonomyFieldValue'
        TermGuid: product.category.key,
        Label: product.category.name,
        WssId: -1
    } : null

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.