0

I have a query that brings the contents of a list based on a query like this:

https://myserver.com/LibraryABC/_api/lists/getbytitle('MyList')/items?$select=*,FileLeafRef&$filter=(MyField eq '700095')

This was working before some changes that were made in Sharepoint. Now the same causes the following error:

<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>-1, Microsoft.SharePoint.SPException</m:code>
<m:message xml:lang="es-ES">
No se puede usar el campo "MyField" de tipo "BusinessData" en la expresión de filtro de consulta.
</m:message>
</m:error>

The error message translation would be something like this:

The field "MyField" of type "BusinessData" cannot be used in an expression of filter or query.

I think they have changed the field to update it from an external source (not sure) so it cannot be queried. Exists some way to overcome this?

Thanks.

  • What is the field type of MyField? – Ganesh Sanap Feb 14 at 13:17
1

We can't use External Data field in REST API $filter.

As a workaround, we can use CAML Query and REST API to instead it.

The method below for your reference:

function getDataWithCaml(listName, caml) {
    var endpoint = _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/GetByTitle('"+ listName + "')/GetItems";
    var requestData = { "query" :
           {"__metadata": 
              { "type": "SP.CamlQuery" }
              , "ViewXml": caml
           }
        };
    return jQuery.ajax({
        url: endpoint,
        method: "POST",
        data: JSON.stringify(requestData),
        headers: {
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "Accept": "application/json; odata=verbose",
            "Content-Type": "application/json; odata=verbose"
        }
    });
}

Refer to: Using CAML with SharePoint REST API

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.