T
Twenty3mo ago
kyrpav

Api Access to Custom View Data

I am trying to use an alternative system for Campaigns. I am not sure if twenty will have solution for Campaigns (mass email solution etc.). So my idea was to get the view data outside of a custom list Or to get all people and reconstruct the filtering. What did i check: I can create a custom view in people page and i can find the view in the api. I can not get the records. I did find that based on viewName and the view api the viewId. i can find the filters applied. Then in the filters i can see that a filter applied to a field (specific fieldmetadataId) should contain a value (and i see the value also) but i do not know the name of the field in the api. Also in the api for the viewFields you have the same metadataId but you do not have a name. So i can not get All people and find the fields that i need to apply the filters. Any idea?
29 Replies
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
From what I see, neither GraphQL nor REST API expose the name of fields so until someone exposes it in code, there's no way to find out which field is which only from API
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
But you can do it indirect way, since Twenty renders tables with fields using fieldMetadataId, you can get view's all fields with this query in GraphQL and looking up directly in React components of table with Chrome extension, you can match given fieldMetadataId with field's name
query MyQuery {
getCoreViews {
id
name
viewFields {
fieldMetadataId
id
}
}
}
query MyQuery {
getCoreViews {
id
name
viewFields {
fieldMetadataId
id
}
}
}
No description
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
Annoying way I admit but that's the only way I can think of And about solutions for campaigns, Twenty will have them in the future
kyrpav
kyrpavOP3mo ago
so if i do only a direct native query in the db i can get the info. But trying to do this with n8n means that i need to connect also to db. Am i correct?
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
Don't think so since table "viewField" doesn't contain the name of field
kyrpav
kyrpavOP3mo ago
but in the database there is also no field name in the viewfield table. exactly this means that i did not understand your proposal is the name in your query the view name? this is ok i know this and i can get the fields with the metadataID and i know for each metadata field the filter and each value i do not know when i get all people which fieldmetadataID belongs to each column in the query from the API to connect them
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
Yes, the name in query is view's name
kyrpav
kyrpavOP3mo ago
then it is not enough. how the field name is store if it is not in the db directly
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
Field name is stored in database in core."fieldMetadata", to fetch it from API you can do it with metadata API using /fields (this contains names of fields) and /viewFields (this contains info which fields are in which views)
kyrpav
kyrpavOP3mo ago
then i can do a query also from there to get the data or i can make a view in db but it will be probably broken in next update
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
You can do query to get data but I'd say creating view via API is safer
kyrpav
kyrpavOP3mo ago
/fields does not exist in api from what i see. i am watching the api page
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
There is
No description
kyrpav
kyrpavOP3mo ago
No description
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
You have to switch to metadata, not core API
kyrpav
kyrpavOP3mo ago
No description
kyrpav
kyrpavOP3mo ago
aaa ok i was searching for object and field and i could not find them let me check
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
There was a migration from core to metadata some time ago
kyrpav
kyrpavOP3mo ago
So i need to get from CORE { view, view filter, view fields } and then from Metadata { fields , objects }
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
I think you can get all of them from metadata
kyrpav
kyrpavOP3mo ago
the view and view filter and viewfields in metadata are empty
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
They shouldn't be empty, which version are you selfhosting?
kyrpav
kyrpavOP3mo ago
let me check 1.3.0 2025-08-11T00:00:00.000Z
kyrpav
kyrpavOP3mo ago
No description
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
Okay, then in your case that should work
kyrpav
kyrpavOP3mo ago
since in workspace schema and core schema the view table exists . is there any difference when the software saves the view inside the workspace and when it saves it in core? i assume that since always there is a workspace then everything goes in workspace except some generic things. but can the user by his/her actions have any impact?
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
Just to be safe, it's better to do it in core in your case
kyrpav
kyrpavOP3mo ago
ok i will have to do only probably fields and object get from the metadata if i am trying with graphQL can i get the views and the fields in views from core and then the names of fields from metadata in one query?
ɃØĦɆᵾS
ɃØĦɆᵾS3mo ago
No as you're reaching out to 2 different endpoints aka /core and /metadata If both information could be available via 1 endpoint, then yes

Did you find this page helpful?