CreatedBy filter not working. Name not being saved to createdByName column.

I'm using v1.1.1 and the "created by" filter does not seem to work. I have tried this with opportunities as well as notes. The filter returns no results even if the correct name for "created by" is added. A separate question, is it possible to filter by a custom field? E.g. if I create a custom field, is it possible to use that in a filter?
20 Replies
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
Hi, I've checked on newest version and looks like "created by" filter works as expected, could you upgrade your instance to newest version and re-check if you are able to reproduce the problem? About filtering by custom field, it is possible to filter records by said field.
kmbuthia
kmbuthiaOP4w ago
Hi @bob this is good to hear, let me upgrade to the latest version and re-test. Will let you know if successful.
kmbuthia
kmbuthiaOP4w ago
Hello again @bob , I've updated to v1.2.1 (self-hosted on docker) and the created by filter still does not work. Please see these screenshots. In the notes area, I filter using createdby contains "dianah" but no results found even though there certainly is a note created by that person. Perhaps there is something silly I have misunderstood here...but hope to get some guidance.
No description
No description
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
That's weird, the only reason I can think of why this would happen is because of different Unicode characters so even if this looks the same, under the hood they have different codes 🤔 Since Twenty uses GraphQL to fetch records, could you check what does this query returns in GraphQL API?
query FindManyNotes($filter: NoteFilterInput) {
notes(filter: $filter) {
totalCount
__typename
}
}

{
"filter": {
"or": [
{
"createdBy": {
"name": {
"ilike": "%dianah%"
}
}
}
]
}
}
query FindManyNotes($filter: NoteFilterInput) {
notes(filter: $filter) {
totalCount
__typename
}
}

{
"filter": {
"or": [
{
"createdBy": {
"name": {
"ilike": "%dianah%"
}
}
}
]
}
}
No description
kmbuthia
kmbuthiaOP4w ago
Thanks for the response. Using the browser inspection tool, I'm attaching the request being sent to the GraphQL endpoint below. I don't see any special characters being set in the payload. If it helps, the headers in the request are application/json and charset=utf-8....my browser locale is also set to en (English)
kmbuthia
kmbuthiaOP4w ago
Update...I've just checked what the API returns when fetching all the notes...interestingly, all the createdBy values are just " " (empty string)....so this is getting me closer to the root cause. The next question would then be: what would cause createdBy to have a blank string for the name? Example createdBy object being returned is below.
"createdBy": {
"__typename": "Actor",
"source": "MANUAL",
"workspaceMemberId": "d7cde816-fc82-4470-bea1-517a0563886f",
"name": " ",
"context": {}
},
"createdBy": {
"__typename": "Actor",
"source": "MANUAL",
"workspaceMemberId": "d7cde816-fc82-4470-bea1-517a0563886f",
"name": " ",
"context": {}
},
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
My bet is data loss due to bad migration (even though console shows everything has been migrated properly, there was something wrong but never reported) after upgrading or said member has deleted their account (there was a related bug to it but I think it's non-relevant to your case). Is this member properly visible in Settings > Members? What does API return when you run query below? Also, what does database return when you run this query select * from workspace_{id}."workspaceMember" where id = 'd7cde816-fc82-4470-bea1-517a0563886f'?
GraphQL API query

query MyQuery {
workspaceMember(filter: {id: {eq: "d7cde816-fc82-4470-bea1-517a0563886f"}}) {
name {
firstName
lastName
}
id
}
}
GraphQL API query

query MyQuery {
workspaceMember(filter: {id: {eq: "d7cde816-fc82-4470-bea1-517a0563886f"}}) {
name {
firstName
lastName
}
id
}
}
kmbuthia
kmbuthiaOP4w ago
Thanks for getting back to me. I'm looking at the tables in the DB and under the company, note and people tables, the createdByName is empty. A fresh install of v1.1.1 is where I began before upgrading to v1.2.1 On the fresh install of v1.1.1 the dummy records that are usually created do have the createdByName populated with Systemwhich is expected I guess...but every record created after that has an empty createdByName regardless of the user's role. When going to Settings > Members all accounts appear correctly (names are showing) and the user I am testing with has definitely not been deleted. I'm quite doubtful that this is due to a bad migration because the filter has not been working since I fresh installed v1.1.1 As a side note: What's a good way to find the workspace ID? I only have two workspaces but if more are needed later it would be good to know how to inspect the ID of a particular workspace...
No description
No description
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
What's the name of this DB visualizer? DBeaver?
kmbuthia
kmbuthiaOP4w ago
Yes
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
Took me longer than I expected due to weird problems, sorry for that Basically, you have to connect to default database, once you open schemas, there's the ID of workspace (mine are seeded)
No description
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
To connect to default database, you either have to change the name of database or check "Show all databases" checkbox
No description
kmbuthia
kmbuthiaOP4w ago
Thanks for this...I've spotted the above as well on my side. What remains a mystery to me is why this createdByName field is not populated. I've tried creating new records but the behaviour persists. I also upgraded my local instance of twenty to v1.2.1 and I'm able to reproduce the problem locally as well.
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
I believe createdByName is taken from workspace_{id}."workspaceMember" table so if there's a record with empty first and last name, that would explain the reason behind this
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
Update: createdByName is not taken, it's simply duplicated so even when workspace Member account is deleted, creator's data won't be lost
No description
kmbuthia
kmbuthiaOP4w ago
I appreciate you getting back to me. I've checked the workspaceMember table and the nameFirstName and nameLastName values are not empty. The name reflects properly there. I've gone as far as to create an account on TwentyCRM cloud version and the createdBy field there seems to be even worse. The name won't even get captured when I create a record. There is something wrong with how createdBy is being captured and the problem is in the code.
No description
No description
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
I'm reproducing this issue, congratulations on finding a bug! 😄
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
GitHub
Records created without creator · Issue #13579 · twentyhq/twenty
Ticket from Discord: https://discord.com/channels/1130383047699738754/1400780784377266217 Scenario: Log in Using invite link located in Settings > Members, create new account While being logged ...
kmbuthia
kmbuthiaOP3w ago
Thanks for confirming the bug. I was able to find out how to filter by custom fields so that is going to be my workaround for now...but this is still an important thing to fix. One last question if I may, when a new workspace is created, a new DB is created in the naming format workspace_{id} where ID is something auto-generated. Is there a place where the auto-generated ID is stored that will map the name of the workspace to the ID in the DB name? This is what I was trying to ask previously above.
ɃØĦɆᵾS
ɃØĦɆᵾS3w ago
From what I can see, id in workspace_{id} and workspace's id in core.workspace are not the same, probably core.workspace has clean id while workspace_{id} has hashed version of it but I'm not sure where I can find it in code to confirm my hypothesis

Did you find this page helpful?