0

I have a get request which grabs documents and saves them into state:

  public getDocuments() {

    axios
      .get("https://bpkintelogydev.sharepoint.com/_api/search/query?querytext='owstaxIdDocumentx0020Owner0:" + this.state.selectedOption + "'&trimduplicates=true&rowsperpage=100&rowlimit=1000",
        { params:{},
          headers: { 'accept': 'application/json;odata=verbose' }
        })
      .then(response =>
          response.data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results.map(document => ({
          Name: document.Cells.results[3].Value.charAt(0).toUpperCase() + document.Cells.results[3].Value.slice(1),
          'Scheduled Review Date': '10/12/2019',
          Path: document.Cells.results[6].Value.replace('https://bpkintelogydev.sharepoint.com', ''),
          Site: document.Cells.results[36].Value.split("/").pop(),
          'Last Review Date': '25/12/2019',
          View: <a href="#" onClick={()=>window.open(document.Cells.results[6].Value + '?web=1&action=edit')}>View</a>,
          'Mark as Reviewed': <a href='#'>Mark</a>
        }))
      )
      .then(documents => {
        this.setState({
          documents, isLoading: false
        });
      })
      .catch(error => {
        console.log(error);
      });

  }

I want to be able to return the columns Last Review Date, Scheduled Review Date as these are currently hard coded in my function above.

Using the image below which is the column settings for Last Review Date how would I amend my end point to include this column?

End point: "https://bpkintelogydev.sharepoint.com/_api/search/query?querytext='owstaxIdDocumentx0020Owner0:" + this.state.selectedOption + "'&trimduplicates=true&rowsperpage=100&rowlimit=1000"

Adding &selectproperties='Last Review Date' on the end does not work :/

enter image description here

1 Answer 1

1

it will work with the "&selectProperties='ManagedPropertyName,ManagedPropertyName2,...'"

And that is, where your problem is. You are trying with the Display Name of the column and not the ManagedProperyName.

If you add a field (e.g: 'Last Review Date') the Sharepoint crawler will find/create a new crawled property. It will be named something like 'ows_Last_x0020_Review_x0020_Date'. You now need to add that to a 'New Managed Property' - lets call it 'LastReviewDateMP' - set the Type correctly and (at least) 'Retrievable' to true. In the Mappings to crawled properties you add the 'ows_Last_x0020_Review_x0020_Date'

After you have added the new managed property and did a crawl, you could use "&selectProperties='LastReviewDateMP'" in your request.

Hope it helps :)

1
  • <3 thanks a lot !
    – BennKingy
    Jan 20, 2020 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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