1

I am trying to select List Items on a document Library where I was able to successfully do based on ID. But I am trying to see whether it is possible to filter based on custom column. Is it possible to query based on custom column?

This is working:

req.setEndpoint('callout:SPO_Integration/_api/web/lists/getbytitle(\'SalesforceDocuments\')/items(\'1\')/File');

The following option is not working:

req.setEndpoint('callout:SPO_Integration/_api/web/lists/getbytitle(\'SalesforceDocuments\')/items(\'510111329\')/File');

enter image description here

1

To filter by a column other than ID, you need to use $filter, so your call should be something like

req.setEndpoint('callout:SPO_Integration/_api/web/lists/getbytitle(\'SalesforceDocuments\')/items'
    + '?filter=YourCustomField = \'YourCustomValue\'');

This will return an array of list items; if it is the File that you need, you will need to use $expand=File as well.

So in the end you should have

req.setEndpoint('callout:SPO_Integration/_api/web/lists/getbytitle(\'SalesforceDocuments\')/items'
    + '?filter=YourCustomField = \'YourCustomValue\'&$expand=File');

You may also want to look into using $select to limit your results to only those you require.

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.