* Delete the given field. * * @param fieldId the field to be deleted. * @param conversion * When deleting a field as an associated field, * mark whether the associated field of the associated datasheet is deleted or converted to text, * the default is Converted to a text field.
(fieldId: string, conversion?: Conversion)
| 675 | * ``` |
| 676 | */ |
| 677 | async deleteField(fieldId: string, conversion?: Conversion): Promise<void> { |
| 678 | // Check the primary column. It is allowed to delete the primary column. After deletion, the datasheet will crash. |
| 679 | if (this.checkPrimaryField(fieldId!)) { |
| 680 | throw new Error(`${fieldId} is Primary field, cannot be deleted`); |
| 681 | } |
| 682 | const result: ICollaCommandExecuteResult<any> = await cmdExecute({ |
| 683 | cmd: CollaCommandName.DeleteField, |
| 684 | data: [{ |
| 685 | deleteBrotherField: conversion === Conversion.Delete, |
| 686 | fieldId, |
| 687 | }], |
| 688 | }, this.wCtx.id); |
| 689 | if (result.result === ExecuteResult.Fail) { |
| 690 | throw new Error(result.reason); |
| 691 | } |
| 692 | if (result.result === ExecuteResult.None) { |
| 693 | throw new Error('Delete field method has been ignored'); |
| 694 | } |
| 695 | return result.data; |
| 696 | } |
| 697 | |
| 698 | /** |
| 699 | * Checks whether the current user has permission to create the specified record. |
no test coverage detected