Fix add related records to activity target after object renaming (#16953)

Fixes https://github.com/twentyhq/twenty/issues/16928 and
https://github.com/twentyhq/private-issues/issues/400

When an object is renamed, its corresponding relation field on
noteTarget and taskTarget are not renamed. This caused an issue as in
the FE, we used the related record object name to compute the field name
used in the payload.
This PR addresses it by, instead, finding the field name after
identifying it thanks to the object id.

To reproduce, you can rename an object then try to tie it to a note.
This commit is contained in:
Marie
2026-01-06 16:26:26 +01:00
committed by GitHub
parent 13bc04047e
commit 12189b378f
7 changed files with 178 additions and 77 deletions
@@ -28,12 +28,14 @@ export const useActivityTargetsForTargetableObjects = ({
activityTargetsOrderByVariables: RecordGqlOperationOrderBy;
limit: number;
}) => {
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
const activityTargetsFilter = getActivityTargetsFilter({
targetableObjects: targetableObjects,
activityObjectNameSingular: objectNameSingular,
objectMetadataItems,
});
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
const FIND_ACTIVITY_TARGETS_OPERATION_SIGNATURE =
findActivityTargetsOperationSignatureFactory({
objectNameSingular,