Problem: You have an external list that you want to filter based on a URL you construct in a code solution. A common scenario might include an email message with a formatted hyperlink that points to a single list item in an external list.
Solution: SharePoint lists have a rich mechanism for refining the items displayed in a view through the FilterField and FilterValue query string parameters. For each filter you want to apply to the list, append the two parameters providing the internal name of a field along with the value to match. Index each pair respectively as in the following example:
This query string assumes the State and Approved fields defined as FilterField are part of the external content type. The FilterValue elements then specify the constraint to place on the return results.
The following list outlines some of the key characteristics of how this feature works:
- You can define filters for any field that is part of an external content type the list is referencing, not just the fields that are part of the view. For example, if the external content type contains the State field but the view you are referring to in the URL doesn’t, you can still include the filter for the State field and it will filter out the list items as expected. Note that when you choose a field that is not part of the view, you will not see a filter indicator next to any columns rendered in the result set.
- For the content type field of type Yes/No (Boolean), use 1 and 0 to indicate Yes and No value respectively.