Error getting an object with filter from a relation field
I'm trying to filter
opportunities
using the pointOfContactId
as filter, but it's throwing the following error:
"Field 'pointOfContactId' does not exist in the 'opportunity' object."
Looking into the issue, in packages/twenty-server/src/engine/api/rest/core/query-builder/utils/filter-utils/parse-filter.utils.ts
, the **checkFields**
function is being called. This function inspects the database fields, and after adding some console.log statements, I noticed that it's looking for pointOfContactId
in the fieldMetadata items.
However, only pointOfContact exists there β not pointOfContactId. Because of that, any attempt to filter by a relation's ID ends up throwing this error.
Does that make sense?
Let me know if it's unclear. I made a quick fix to get past it, but I'm sure it's not the ideal solution π

3 Replies
@prastoin could you please check this for me?
Hey @Mauricio Natacci indeed nice catch !
I'm able to reproduce
Created an issue https://github.com/twentyhq/twenty/issues/12921
We should fallback the field to the relation key field
Thanks a lot @prastoin . I really appreciate it!