T
Twenty2w ago
kyrpav

How to get user that updated a record.

it seems that in created by there is an Actor. but i can not make another field updated by to set it to Actor also. I can select workspace members but this should not be selectable. Consept is to create a correction tasks for the person that broke a record listing all the mistakes
25 Replies
martmull
martmull2w ago
Hey, updatedBy is not implemented yet but it is planned to be
kyrpav
kyrpavOP2w ago
do we have idea when?
ɃØĦɆᵾS
ɃØĦɆᵾS2w ago
I'm trying to make an extension for this, it's almost done, but I have to figure out how to update properly the field via API as it normally results in error from unique constraint
ɃØĦɆᵾS
ɃØĦɆᵾS2w ago
GitHub
twenty/packages/twenty-apps/updated-by at updated_by · BOHEUS/twenty
Building a modern alternative to Salesforce, powered by the community. - BOHEUS/twenty
ɃØĦɆᵾS
ɃØĦɆᵾS2w ago
I have yet to understand why this works separated in test.ts but not in extension
kyrpav
kyrpavOP2w ago
Also there is another issue on this tasks. when in workflow you want to create a task you can not set the relation object
No description
kyrpav
kyrpavOP2w ago
so i can even not decide to assign unti you fix it the creator but i can not connect the task to the object that i refer
ɃØĦɆᵾS
ɃØĦɆᵾS2w ago
CC: @thomast What would be the perfect way to do it? Create a generic workspaceMember relation type field like ACTOR with post-update hook checking if update was done by user and not by API and updated field isn't updatedBy? Won't lie, can't figure out a way to bypass the constraint via API in app even though it's working outside the app
kyrpav
kyrpavOP2w ago
it seems that here we have in this chat 2 issues: * Updated By is not available and you can not set actor to a field if you want to created this field manually * creation of task by workflow does not give you the possibility to set relation field. Is it possibile to know when could these be fixed if they are already in plan?
sourcedandsoldtothehighestbidder
Yeah I am also having the same issue here
ɃØĦɆᵾS
ɃØĦɆᵾS2w ago
@Weiko what are the requirements for Twenty ORM to throw the violation of foreign key exception?
Weiko
Weiko2w ago
The metadata layer is directly using TypeORM, only Workspace schema record CRUD goes though TwentyORM. Which constraint is failing during your field update?
ɃØĦɆᵾS
ɃØĦɆᵾS2w ago
Response from server container
error: error: insert or update on table "company" violates foreign key constraint "FK_fc412fe0b566cebef3f469332cd"
Exception Captured
{ user: undefined, workspace: undefined }
[
InternalServerErrorException: insert or update on table "company" violates foreign key constraint "FK_fc412fe0b566cebef3f469332cd"
at HttpExceptionHandlerService.handleError (/home/user/Desktop/projects/twenty/packages/twenty-server/src/engine/core-modules/exception-handler/http-exception-handler.service.ts:108:19)
at RestApiExceptionFilter.catch (/home/user/Desktop/projects/twenty/packages/twenty-server/src/engine/api/rest/rest-api-exception.filter.ts:25:45)
at ExceptionsHandler.invokeCustomFilters (/home/user/Desktop/projects/twenty/node_modules/@nestjs/core/exceptions/exceptions-handler.js:33:26)
at ExceptionsHandler.next (/home/user/Desktop/projects/twenty/node_modules/@nestjs/core/exceptions/exceptions-handler.js:13:18)
at /home/user/Desktop/projects/twenty/node_modules/@nestjs/core/router/router-proxy.js:13:35
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at /home/user/Desktop/projects/twenty/node_modules/@nestjs/core/router/router-explorer.js:166:17 {
response: {
statusCode: 500,
message: 'insert or update on table "company" violates foreign key constraint "FK_fc412fe0b566cebef3f469332cd"',
error: 'Internal Server Error'
},
status: 500,
options: {}
}
]
error: error: insert or update on table "company" violates foreign key constraint "FK_fc412fe0b566cebef3f469332cd"
Exception Captured
{ user: undefined, workspace: undefined }
[
InternalServerErrorException: insert or update on table "company" violates foreign key constraint "FK_fc412fe0b566cebef3f469332cd"
at HttpExceptionHandlerService.handleError (/home/user/Desktop/projects/twenty/packages/twenty-server/src/engine/core-modules/exception-handler/http-exception-handler.service.ts:108:19)
at RestApiExceptionFilter.catch (/home/user/Desktop/projects/twenty/packages/twenty-server/src/engine/api/rest/rest-api-exception.filter.ts:25:45)
at ExceptionsHandler.invokeCustomFilters (/home/user/Desktop/projects/twenty/node_modules/@nestjs/core/exceptions/exceptions-handler.js:33:26)
at ExceptionsHandler.next (/home/user/Desktop/projects/twenty/node_modules/@nestjs/core/exceptions/exceptions-handler.js:13:18)
at /home/user/Desktop/projects/twenty/node_modules/@nestjs/core/router/router-proxy.js:13:35
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at /home/user/Desktop/projects/twenty/node_modules/@nestjs/core/router/router-explorer.js:166:17 {
response: {
statusCode: 500,
message: 'insert or update on table "company" violates foreign key constraint "FK_fc412fe0b566cebef3f469332cd"',
error: 'Internal Server Error'
},
status: 500,
options: {}
}
]
Weiko
Weiko2w ago
Ah, this is not when you update a field but a company, this is going though Twenty ORM then indeed Is it when you run the code from test.ts in the branch you shared above?
ɃØĦɆᵾS
ɃØĦɆᵾS2w ago
This appears only when app is triggered
Weiko
Weiko2w ago
The FK constraint complains because you are probably providing a wrong id for your workspaceMemberId You are adding a new field relation to each object targetting workspaceMembers then you are updating a company providing a variable named userId as a workspaceMemberId value. If it's not a proper workspaceMemberId it will fail
ɃØĦɆᵾS
ɃØĦɆᵾS2w ago
Just to be sure, userId given from Twenty to app when trigger conditions are met is not the same as workspaceMemberId? Okay, thanks for showing me the direction, I solved the problem and updatedBy plugin should work properly now I'll try to create a PR once I get a proper internet connection and some testing
ɃØĦɆᵾS
ɃØĦɆᵾS2w ago
GitHub
Updated by extension by BOHEUS · Pull Request #15937 · twentyhq/t...
Working updated by extension which shows the workspace member behind the newest change
Weiko
Weiko2w ago
Yes, not the same indeed, you need to fetch workspaceMemberId instead and it should be in the payload as well. Seems like you figured it out yourself 🙂
ɃØĦɆᵾS
ɃØĦɆᵾS5d ago
@kyrpav extension has been merged, feel free to test it out and give feedback on it!
kyrpav
kyrpavOP5d ago
11.5? or it will be then later released as docker?
ɃØĦɆᵾS
ɃØĦɆᵾS5d ago
As far as I know, you have to clone the repo or specific folder and go with instructions attached to app It's not bundled together with Twenty, @martmull are there plans for extensions app shop?
Weiko
Weiko5d ago
Yes, no timeline yet but this is planned
kyrpav
kyrpavOP5d ago
I am using 1.11.5 latest Dockerised version. What is the procedure to install the application? I have seen the readme page to install this extension app.Is there any guide on how to do it in dockerised version.
ɃØĦɆᵾS
ɃØĦɆᵾS2d ago
Currently there's no other way than: - downloading twenty-cli - cloning whole repo - going to packages/twenty-apps/community/updated-by - twenty auth login - twenty app sync - adding required variables in Settings > Integrations > Updated by One optimization can be done with cloning only specific folder within whole folder (or submodule once core team extracts whole twenty-apps module to separate repo) but that's something I have yet to figure out

Did you find this page helpful?