Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How can we use filter in graphql (/o/api) to filter based on custom fie
I need to fetch all users from the Liferay (GraphQL) based on the value of the custom field
I am using GraphQL in Liferay from /o/api
I am only able to filter the data based on email ID and user ID, here is my query for that
=======================================================================================
query {
userAccounts(filter:"emailAddress eq 'test@liferay.com'"){
items{
emailAddress
id
name
customFields{
name
customValue{
data
}
}
}
}
}
=======================================================================================Result:======================================================================================={
"data": {
"userAccounts": {
"items": [
{
"emailAddress": "test@liferay.com",
"id": 20126,
"name": "Test Test",
"customFields": [
{
"name": "Speciality",
"customValue": {
"data": [
"Cardiologia"
]
}
}
]
}
]
}
}
}
=======================================================================================
but i want to filter based on value of the custom fieldName of the custom field: "Speciality" and possible (selectable) value is {Cardiologia, Dermatologia, vagh3}I have tried lot's of way to achieve this but every time failed........I am loosing my hopeCan we filter the data based on custom fields? and if Yes, then how?????
I am using GraphQL in Liferay from /o/api
I am only able to filter the data based on email ID and user ID, here is my query for that
=======================================================================================
query {
userAccounts(filter:"emailAddress eq 'test@liferay.com'"){
items{
emailAddress
id
name
customFields{
name
customValue{
data
}
}
}
}
}
=======================================================================================Result:======================================================================================={
"data": {
"userAccounts": {
"items": [
{
"emailAddress": "test@liferay.com",
"id": 20126,
"name": "Test Test",
"customFields": [
{
"name": "Speciality",
"customValue": {
"data": [
"Cardiologia"
]
}
}
]
}
]
}
}
}
=======================================================================================
but i want to filter based on value of the custom fieldName of the custom field: "Speciality" and possible (selectable) value is {Cardiologia, Dermatologia, vagh3}I have tried lot's of way to achieve this but every time failed........I am loosing my hopeCan we filter the data based on custom fields? and if Yes, then how?????
Hi Bhargav Vaghasiya.
I was investigating about that and I found this: https://github.com/liferay/liferay-portal/blob/master/modules/apps/headless/headless-admin-user/headless-admin-user-impl/src/main/java/com/liferay/headless/admin/user/internal/odata/entity/v1_0/UserAccountEntityModel.java
It seems like the filter for custom fields for user accounts is not supported yet.
But, if you have created your custom field searchable, you can search the Speciality by its value. I mean, you can do something like this:
query {
userAccounts(search: "dermatologia") {
items {
emailAddress
id
name
customFields {
name
customValue {
data
}
}
}
}
}
And received the following response
{
"data": {
"userAccounts": {
"items": [
{
"emailAddress": "luismitest@liferay.com",
"id": 38306,
"name": "luismi test",
"customFields": [
{
"name": "Speciality",
"customValue": {
"data": "Dermatologia"
}
}
]
}
]
}
}
}
Hope this helps you.
I was investigating about that and I found this: https://github.com/liferay/liferay-portal/blob/master/modules/apps/headless/headless-admin-user/headless-admin-user-impl/src/main/java/com/liferay/headless/admin/user/internal/odata/entity/v1_0/UserAccountEntityModel.java
It seems like the filter for custom fields for user accounts is not supported yet.
But, if you have created your custom field searchable, you can search the Speciality by its value. I mean, you can do something like this:
query {
userAccounts(search: "dermatologia") {
items {
emailAddress
id
name
customFields {
name
customValue {
data
}
}
}
}
}
And received the following response
{
"data": {
"userAccounts": {
"items": [
{
"emailAddress": "luismitest@liferay.com",
"id": 38306,
"name": "luismi test",
"customFields": [
{
"name": "Speciality",
"customValue": {
"data": "Dermatologia"
}
}
]
}
]
}
}
}
Hope this helps you.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™