object Object error in SPfx
-
13-02-2021 - |
Question
Trying below code to read Site column but getting value as [object Object] OnClick
Function:
onClick={()=>{this.Funnel(items.SiteColumn)}}
Complete function code:
public render(): React.ReactElement<IAutomationProps>
{
return (
<div style={divStyle} >
{this.state.items.map((items,key)=>
{
return(
<DocumentCard
aria-label={items.RatingCount} styles={cardStyles}
onClick={()=>{this.Funnel(items.SiteColumn)}}
>.
<DocumentCardImage height={150} imageFit={ImageFit.cover} imageSrc={items.Picture? items.Picture["Url"] : ''} />
<DocumentCardDetails>
<DocumentCardTitle title={items.Title} shouldTruncate />
<label >{items.RatingCount}</label>
</DocumentCardDetails>
</DocumentCard> );
})}
</div>
);
La solution
Multiple selection choice column will be returned in following JSON format while using SharePoint REST API:
"Product_x0020_Catalogue": {
"__metadata": {
"type": "Collection(Edm.String)"
},
"results": [
"Enter Choice #1",
"Enter Choice #2"
]
}
So you need to use items.Product_x0020_Catalogue.results
to get the array of multiple selected choice values.
Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange