Skip to content

The open alternative to Salesforce, designed for AI.

Allow isActive to be updated for standard objects (#2651)

Weiko0fd823af21f5
diff --git a/server/src/metadata/field-metadata/hooks/before-update-one-field.hook.ts b/server/src/metadata/field-metadata/hooks/before-update-one-field.hook.ts
index bac26cb286e..9b1532e3026 100644
--- a/server/src/metadata/field-metadata/hooks/before-update-one-field.hook.ts
+++ b/server/src/metadata/field-metadata/hooks/before-update-one-field.hook.ts
@@ -40,7 +40,22 @@ export class BeforeUpdateOneField<T extends UpdateFieldInput>
}
if (!fieldMetadata.isCustom) {
- throw new BadRequestException("Standard Fields can't be updated");
+ if (
+ Object.keys(instance.update).length === 1 &&
+ instance.update.hasOwnProperty('isActive') &&
+ instance.update.isActive !== undefined
+ ) {
+ return {
+ id: instance.id,
+ update: {
+ isActive: instance.update.isActive,
+ } as T,
+ };
+ }
+
+ throw new BadRequestException(
+ 'Only isActive field can be updated for standard fields',
+ );
}
this.checkIfFieldIsEditable(instance.update);
diff --git a/server/src/metadata/object-metadata/hooks/before-update-one-object.hook.ts b/server/src/metadata/object-metadata/hooks/before-update-one-object.hook.ts
index 8a2ffee399f..321d04d6bcf 100644
--- a/server/src/metadata/object-metadata/hooks/before-update-one-object.hook.ts
+++ b/server/src/metadata/object-metadata/hooks/before-update-one-object.hook.ts
@@ -48,7 +48,22 @@ export class BeforeUpdateOneObject<T extends UpdateObjectInput>
}
if (!objectMetadata.isCustom) {
- throw new BadRequestException("Standard Objects can't be updated");
+ if (
+ Object.keys(instance.update).length === 1 &&
+ instance.update.hasOwnProperty('isActive') &&
+ instance.update.isActive !== undefined
+ ) {
+ return {
+ id: instance.id,
+ update: {
+ isActive: instance.update.isActive,
+ } as T,
+ };
+ }
+
+ throw new BadRequestException(
+ 'Only isActive field can be updated for standard objects',
+ );
}
if (