Issue
When extending a system object, such as the User object, with a custom object field (e.g., customID), attempting to filter user accounts by this custom field using the headless API results in an error. The API call looks like this:
/o/headless-admin-user/v1.0/user-accounts?filter=customID eq 'xxxxx'BAD_REQUEST response, even if the custom field is indexed as a keyword and a full re-index has been performed:{ "status": "BAD_REQUEST", "title": "A property used in the filter criteria is not supported: customID eq 'xxxxx'", "type": "InvalidFilterException" }
Environment
-
Liferay DXP (all versions)
Resolution
This behavior is expected due to a current product limitation. The Headless API does not support filtering on custom fields that have been added to system User objects.
As a workaround, use Custom Fields (Expandos) instead of object fields. The headless API supports filtering on Expandos via the customFields path.
To filter by a User Custom Field, structure the API call as follows:
GET /o/headless-admin-user/v1.0/user-accounts?filter=customFields/yourCustomFieldName eq 'yourValue'
For example, if you create a User Custom Field with the name customID, the request would be:
GET /o/headless-admin-user/v1.0/user-accounts?filter=customFields/customID eq 'xxxxx'200 OK response with the correctly filtered user accounts.