0

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>
                );
8
  • What is stored inside items? from where you want to read the site column? – Ganesh Sanap Jul 4 '20 at 15:56
  • items:data.d.result from rest api and site column is Choice column, Checkboxes(allow multiple selections) – kumar Jul 4 '20 at 16:08
  • What is the internal name of your column? and value you are getting in this.Funnel() function? – Ganesh Sanap Jul 4 '20 at 16:34
  • 1
    Try using items.Product_x0020_Catalogue.results to get the array of multiple selected choice values. – Ganesh Sanap Jul 4 '20 at 17:01
  • 1
    Is it working for you? – Ganesh Sanap Jul 4 '20 at 17:18
1

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.

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.