MCPcopy Create free account
hub / github.com/apitable/apitable / deleteField

Method deleteField

packages/widget-sdk/src/model/datasheet.ts:677–696  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 2

deleteFieldAsyncMethod · 0.45
datasheet.spec.tsFile · 0.45

Calls 2

checkPrimaryFieldMethod · 0.95
cmdExecuteFunction · 0.90

Tested by

no test coverage detected