import * as React from 'react' ; import styles from './SpfxPnpGetset.module.scss' ; import { ISpfxPnpGetsetProps } from './ISpfxPnpGetsetProps' ; import { ISpfxPnpGetsetState } from './ISpfxPnpGetsetState' ; import { sp } from "@pnp/sp" ; import "@pnp/sp/webs" ; import "@pnp/sp/lists" ; import "@pnp/sp/items" ; import "@pnp/sp/site-users/web" ; import { ISiteUserProps } from "@pnp/sp/site-users/" ; import "@pnp/sp/fields" ; export default class SpfxPnpGetset extends React . Component < ISpfxPnpGetsetProps , ISpfxPnpGetsetState > { constructor ( props , state ) { super ( props ) ; this . _getListItem ( ) ; } private async _getListItem ( ) { const list = sp . web . lists . getByTitle ( "GetSet" ) ; const item = await list . items . getById ( 1 ) . get ( ) ; let textvalue = item [ "Title" ] ; let multipleLineTextValue = item [ "MultipleLinesText" ] ; let multipleLineHTMLValue = item [ "MultipleLinesHTML" ] ; let singleChoice = item [ "Location" ] ; let multiChoice = item [ "Locations" ] ; let numvervalue = item [ "Quantity" ] ; let currencyvalue = item [ "Cost" ] ; let datevalue = item [ "BirthDay" ] ; let lookupvalue = item [ "ColorId" ] ; let lookupvalues = item [ "ColorsId" ] ; let yesnovalue = item [ "IsActive" ] ; let uservalue = item [ "OwnerId" ] ; let usersvalue = item [ "OwnersId" ] ; let linkvalue = item [ "Reference" ] ; const Description = linkvalue [ "Description" ] ; const Url = linkvalue [ "Url" ] ; let tagvalue = item [ "Tag" ] ; const i = await list . items . getById ( 1 ) . update ( { Title : textvalue , MultipleLinesText : multipleLineTextValue , MultipleLinesHTML : multipleLineHTMLValue , Location : singleChoice , Locations : { results : multiChoice } , Quantity : numvervalue , Cost : currencyvalue , BirthDay : datevalue , ColorId : lookupvalue , ColorsId : { results : lookupvalues } , IsActive : yesnovalue , OwnerId : uservalue , OwnersId : { results : uservalue } , Reference : { "__metadata" : { type : "SP.FieldUrlValue" } , Description : Description , Url : Url } , Tag : { "__metadata" : { "type" : "SP.Taxonomy.TaxonomyFieldValue" } , "Label" : tagvalue . Label , 'TermGuid' : tagvalue . TermGuid , 'WssId' : '-1' } } ) ; let tagsvalue = item [ "Tags" ] ; let tagsString = '' ; tagsvalue . forEach ( function ( v , i ) { tagsString += `${ v . Label }|${ v . TermGuid };` ; } ) ; const ir = await list . items . getById ( 1 ) . validateUpdateListItem ( [ { ErrorMessage : null , FieldName : "Tags" , FieldValue : tagsString , HasException : false } ] ) ; } public render ( ) { return ( < div className = { styles . spfxPnpGetset } > This web part just for explain how to set and set value into SharePoint using PnP js < /div>); } }