diff --git a/src/controllers/04-flow-template-controller.ts b/src/controllers/04-flow-template-controller.ts index a76e137..b178e06 100644 --- a/src/controllers/04-flow-template-controller.ts +++ b/src/controllers/04-flow-template-controller.ts @@ -272,12 +272,17 @@ export class FlowTemplateController extends Controller { deleteMany: {}, create: v.value?.map((val) => ({ value: val })), }, - responsiblePerson: { - createMany: { - data: v.responsiblePersonId?.map((id) => ({ userId: id })) || [], - skipDuplicates: true, - }, - }, + responsiblePerson: v.responsiblePersonId + ? { + deleteMany: { + userId: { notIn: v.responsiblePersonId }, + }, + createMany: { + data: v.responsiblePersonId?.map((id) => ({ userId: id })) || [], + skipDuplicates: true, + }, + } + : undefined, responsibleInstitution: { deleteMany: {}, create: v.responsibleInstitution?.map((group) => ({ group })),